Write the class specification constructor accessors and


Question 1:

This question is based on contents covered in Chapter 10 of text. The objectives of the questions are to:

• access if students have understood the basic concepts of object-oriented class
• write the class specification, constructor, accessors and mutators
• write test driver to test the written methods

Examine the following class diagram, additional information and answer the questions that follow:

CarSpeed

acceleration: float engine_number: string start: bool
CarSpeed(float = 0, string = "", bool = false) start_car():void
stop_car():void set_acceleration(float): void set_engine_number(string): void get_velocity(float): float

(a) List FOUR characteristics of a constructor.

(b) Develop C++ code to implement the CarSpeed specification.

(c) Develop C+ code to implement ALL methods found in the CarSpeed class.

(d) Inspect the sample output and write a test driver to test and fulfil at least the following requirements.

Uses a loop that repeats 3 times to prompt the user to enter the engine number, acceleration and time, use the various mutators to set the engine number, acceleration & time, invokes the respective method to display the velocity. The velocity is displayed with 2 decimal places.

Question 2

This question is based on contents covered in Chapter 10 and 11 of text. The objectives of the questions are to:
• Implement the constructor, assessors, mutators and methods
• understand object composition
• write test driver to test the written methods

You are required to write the declaration and implementation code in separate files. Your submission is expected to reflect this.

Examine the following class specifications, additional information and answer the questions that follow:

class Date
{
int dd; int mm; int yy;
public:
Date(int = 1, int=1, int=2015); void setDate(int, int, int); int getDD();
int getMM(); int getYY();
};
class Appointment
{
private:
string NRIC; string name; double fees; Date visit; Date nextVisit;
public:
Appointment();
void setAppt(string, string, double, Date, Date); Date getVisit();
Date getnextVisit(); string getName(); void displayAppt();
void displayAppt(name);
};

(a) Define function overloading. Identify the overloaded function(s) found in the given class(es).

(b) Develop C++ code to implement ALL the methods found in the above class specifications

(i) Date Class

(ii) Appointment Class

(c) Write a test driver to test ALL the methods in the Date and Appointment classes. The test driver should at least include the following:
(i) declare an array of 4 Appointment
(ii) initialised the array of Appointment objects with the data from the following test data
(iii) display all appointment objects, using displayAppt method
(iv) display a single appointment object, using displayAppt(string) method, passing in the NRIC value, "S56783".

Include a screen output similar to the sample output in your submission.

Question 3

This question is based on contents covered in Chapter 6 of text. The objectives of the question are to:

(a) implement the methods as per given class requirements
(b) write the test driver to test the given methods
(c) write file processing code

Examine the given class specification, data files, additional information and answer the questions that follows:

class Format
{
private:
int number; public:
void writeFile();
};

(a) Define ifstream and ofstream.

(b) Using C++ code, develop the writeFile method, fulfilling the requirement stated in the

Additional Information above.

(c) Write a test driver to test the following:
• instantiate one instance of Format,
• invokes the writeFile method

Question 4

This question is based on contents covered in Chapter 10 and 15 of text. The objectives of the question are to:

(a) assess students' understanding of the basic concept of inheritance in C++.

(b) write code demonstrating their understanding of inheritance.

(c) assess if students have understood the basic concept of dynamic binding.

Study the given class diagrams, additional information and answer questions that follow:

Pledge
amt1: float
Pledge(); Pledge(float = 1.00);
virtual add_pledge(float): void virtual get_pledge():float; virtual display():void

SpecialPledge
*amt2: float
SpecialPledge(float); add_pledge(float): void get_pledge():float display():void

(a) Using C++ code, construct the class specification for
(i) Base class: Pledge

(ii) Derived class: SpecialPledge

(b) Write C++ code to implement the constructor and methods found in
(i) Pledge

(ii) SpecialPledge

(c) Write a test driver to fulfil at least the following requirements:

• Declare a vector array of 2 Pledge objects
• Use the new operator to instantiate two objects:
(i) one Pledge object with the value 200
(ii) one SpecialPledge object with the value 50

• Invoke ALL the methods
• See sample output (bold and highlighted) to see the testing of ALL methods.

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: Write the class specification constructor accessors and
Reference No:- TGS01205899

Expected delivery within 24 Hours