Question: c++ , I need help in this question please The following is a specification of three classes: Class Phone: Attributes: Age, an integer The age

c++ , I need help in this question please

The following is a specification of three classes:

Class Phone:

Attributes:

Age, an integer The age of the vehicle

Price, a float The first name of the vehicle

Behaviors:

Phone() default constructor sets age=0, and price=0.0

Phone(int a, float b) parameterized constructor, which sets

age=a, and price=b

setAge() Takes an integer parameter, returns nothing

setPrice() Takes a float parameter, returns nothing

getAge() Takes no parameters, returns the vehicles age

getPrice() Takes no parameters, returns the vehicles price

End Class Phone

Class IPhone: // It should be a derived class from Phone

Attributes:

An object of type IPhone has all the attributes of an

object of type Phone

Additionally, IPhone have attributes that Phone do not:

Apple Id, an integer

Behaviors:

An object of type IPhone has all the behaviors of an object of

type Phone

Additionally, IPhone have behaviors that Vehicles do not:

IPhone() default constructor sets AppleID to 0

setAppleID(int x) Takes an integer parameter, set Apple ID, and

returns nothing

getAppleID() Takes no parameters, returns the IPhones Apple ID

End Class IPhone

Class IPhone8: // It should be a derived class from IPhone

Attributes:

An object of type IPhone8 has all the attributes of an

object of type IPhone

Additionally, IPhone8 has attributes that IPhone does not:

AugmentedRealityStatus, a boolean yes or no

Behaviors:

An object of type IPhone8 has all the behaviors of an object of

type IPhone

Additionally, IPhone8 has behaviors that IPhone does not:

IPhone8() default constructor sets DieselTypeStatus=false

setAugmentedRealityStatus(bool x) Takes a boolean parameter, set the status, and returns nothing

getAugmentedRealityStatus() Takes no parameters, returns the IPhone8s augmented reality type status

End IPhone8

It would be a horrible waste of valuable programming time to redefine all of the functions in IPhone or IPhone8 when many of them are already defined. This assignment is to reinforce the application of inheritance.

Requirements:

1.) Draw three UML class diagrams, one for each of the classes mentioned above

2.) Draw a generalization among the three class diagrams, showing the inheritance relationship.

  1. Implement the three classes described earlier (Phone, IPhone and IPhone8) and write a driver function (main) in order to test them. For the testing, write the following test code in your main( ) :

Phone x;

cout << Initial value for x: << endl;

cout << Age = << x.getAge() << Price= << x.getPrice() << endl;

x.setAge(3);

x.setPrice(200);

cout << Modified value for x: << endl;

cout << Age = << x.getAge() << Price= << x.getPrice() << endl;

IPhone y;

cout << Initial value for y: << endl;

cout << Age = << y.getAge() << Price= << y.getPrice() << Apple ID= << y.getAppleID() << endl;

y.setAge(2);

y.setPrice(300);

y.setAppleID(1234);

cout << Modified value for y: << endl;

cout << Age = << y.getAge() << Price= << y.getPrice() << Apple ID= << y.getAppleID() << endl;

IPhone8 z;

cout << Initial value for z: << endl;

cout << Age = << z.getAge() << Price= << z.getPrice() << Apple ID= << z.getAppleID() << AugmentedReality status= << z.getAugmentedRealityStatus( ) << endl;

z.setAge(1);

z.setPrice(500);

z.setAppleID(3234);

z.setAugmentedRealityStatus(true);

cout << Modified value for z: << endl;

cout << Age = << z.getAge() << Price= << z.getPrice() << Apple ID= << z.getAppleID() << AugmentedReality status= << z. getAugmentedRealityStatus( ) <

Display the results in tabular format (one is already done for you) as follows:

Value used for test, and what function(s)

Reason for Test

Expected Result

Actual Result

setAge( 15 )

To ensure that the age is setting the value properly, and that getAge( ) is returning

After setAge(15) is called, getAge() should return 15.

After using cout<< on the member function getAge(), 15 was printed.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!