Vous êtes sur la page 1sur 2

Assignment No.

05 Total Marks: 20
Semester: Fall 2009
CS201: Introduction to Programming Due Date: 27-01-2010

Instructions
Please read the following instructions carefully before submitting
assignment:
It should be clear that your assignment will not get any credit if:

 The assignment is submitted after due date.


 The submitted assignment does not open or file is corrupt.
 All types of plagiarism are strictly prohibited.

Note: You have to upload only .cpp file. Assignment in any other format
(extension) will not be accepted. If you will submit code in .doc (Word
document) you will get zero marks.

Objective
The objective of this assignment is to provide hands on experience of using

 Basic concepts of C++ language and Programming


 Constructors of C++ language
 Object and classes of C++ language
 etc
Guidelines
 Code should be properly aligned and well commented.
 Follow c/c++ rules while writing variables names, function names etc
 Use only dev-C++ for this assignment.

Assignment

Problem Statement:

Suppose we have a class named as Train it has two constructors, two methods, and a single attribute each of
which described as follows:

• One attribute:
maxSpeed – an int value representing the maximum speed of the Train object.

Note: Train speed of modern Trains may be something like 250 km per hour, so a value
you could use for testing purposes is 250.
• Two constructors:
A default constructor:
A constructor that initializes the attribute ms where ms is the maxSpeed.
An overloaded constructor:
A constructor that takes ms as an argument, where ms is the maxSpeed.

• Two methods:
getMaxSpeed() – return the maxSpeed value associated with the Train object.
setMaxSpeed(ms) – change the maxSpeed value associated with the Train object, where
ms is the new value.

• Display the value through default constructor and overloaded constructor.


• Display setter value through main function.

Deadline
Your assignment must be uploaded/submitted on or before 27-01-2010

Vous aimerez peut-être aussi