Assignment 2 2016 Nov
Assignment 2 2016 Nov
Level 1 Semester 1
ITE 1101 - Fundamentals of Programming
Assignment 02
1. Create a class called Bicycle which has four integer member variables called gear,
cadence, speed and ID and one class variable called noOfBicycles to count the how many
bicycle objects created.
Define a constructor to bicycle class, which has three arguments to initialize the gear,
cadence, speed of the bicycle object when it is created. Inside the constructor you must
initialize the ID by using following statement;
ID = ++ noOfBicycles;
Define a new member function getID() to return the id of the bicycle and define a class
method getNumberOfBicycles() to returns the no of bicycle object.
Create a new class called MountainBike which derived from Bicycle class and it has an
own member variable called seatHeight to store the height of the seat.
Define a constructor to MountainBike class, which has four arguments (to initialize the
gear, cadence, speed and seatheight).
Hint: inside the constructor, call the suitable constructor of the super class by
passing the suitable variables to it and initialize the seatHeight instance variable.
Define a member function called getSeatHeight() to output the seat height of the
MountainBike object.
Create another class called BicycleClass which have a main method and create two
mountain bike objects b1 and b2 using MountainBike constructor. Then display the bike
IDs as follows.
2. Create a new class called TandemBike which derived from Bicycle class and it has an
own member variable called noOfHeaders to store number of handles it has.
Define a constructor to TandemBike class, which has four arguments (to initialize the
gear, cadence, speed and noOfHeaders).
Hint: inside the constructor, call the suitable constructor of the super class by
passing the suitable variables to it and initialize the noOfHeaders.
3. Modify MountainBike and TandemBike classes to count the how many bicycle objects
from each type separately.
Compress all these files under your registration number and upload it to LMS.