Write test driver to test the written methods

Assignment Help C/C++ Programming
Reference no: EM13906608

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.

Reference no: EM13906608

Questions Cloud

Making alteration for goodwill : C resigns on the condition that he be quickly paid the sum because of a great many making alteration for goodwill which is esteemed at Rs. 22,500.
Rework issue 1 accepting the accompanying planned sums : rework issue 1 accepting the accompanying planned sums
Demonstrate the asset report : Pass diary sections to record the aforementioned exchanges and demonstrate the asset report of the firm promptly after A's retirement.
Utilizing the percent of offers technique : Utilizing the percent of offers technique, set up the star forma benefit and misfortune represent year 3. Expect that the deals will be 26,000 in year 3. In the event that profits are raised to 500, what measure of held income can be normal for year3..
Write test driver to test the written methods : write the class specification, constructor, accessors and mutators and write test driver to test the written methods
How many glasses can kevin fill with a full pitcher : Kevin is serving water at a restaurant. The pitcher holds 1 gallon of water. If each glass holds 8 ounces of water, how many glasses can Kevin fill with a full pitcher?
Find the largest permissible value load w : Knowing the allowable normal stress due to bending +110 MPa in tension and -150 MPa in compression, find the largest permissible value load W if beam AB is not overstressed.
Constructs a rectangle object : Write an AreaTester program that constructs a Rectangle object and then computes and prints its area. Use the getWidth and getHeight methods. Also print the unexpected answer.
Implement a class icecreamcone : Implement a class IceCreamCone with methods getSurfaceArea() and getVolumn(). In the constructor, supply the height and radius of the cone. Be careful when looking up the formula for the surface area

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd