Question

C++ PROGRAMMING: Create a program that includes three classes called automobile, frame, and tires. Each of...

C++ PROGRAMMING:

Create a program that includes three classes called automobile, frame, and tires. Each of these classes must do the following:

Frame Class:

Store the data for the size of the frame (tiny, medium, big)

The condition of the frame (bad, decent, good)

The number of tires it can fit. The number of tires it can fit directly depends on the on the size of the automobile. If the automobile is small, it will have three tires. If it is medium it will have four tires, and if it is large it will have eight tires.

The default constructor for the frame should be a medium sized frame that is in decent condition. You also need three more constructors, one that will allow you to set a size for the frame, one that will allow you to set a condition for the frame, and one to get the number of tires.

Tires Class:

The Tires class must contain variables for the following:

Mileage left

The condition of the tire (bad, decent, good)

The default condition for Tires must be decent. A decent tire must have 25,000 miles available, a good tire must have 50,000 miles available, and a poor tire must have 10,000 miles available. Once again, create a default constructor and an additional constructor that overrides the default condition of the tire.

Automobile Class:

The Automobile class is the final product. consisting of the other objects. You must store the following:

Price, Tires, a Frame, and whether or not it is able to be driven (Boolean).

The condition of the frame and the condition of the tires will determine the price of the automobile. The initial price of all automobiles is 500. The frame will apply a scale of 10, 16 or 24 to this, depending on its condition. The condition of each tire will apply a scale of 3, 4 or 5. Also, an automobile becomes drivable once it has the appropriate number of tires added.

Here are some functions you should use that will be helpful:

addTires

getFrame

isItBuilt- returns a Boolean for whether or not the frame and all tires have been added

testDrive- will take the automobile for a test drive. The integer ittakes in should be the mileage you want the automobile to travel. (Note: mileage affects the price of the automobile)

Display – should print all the information of an automobile and its frame and tires.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

C++ code:

#include<iostream>

using namespace std;

class Frame

{

string size,condition;

int number;

public:

void setSize(string sz)

{

size=sz;

}

void setCondition(string cn)

{

condition=cn;

}

void setNumber(int n)

{

number=n;

}

void printFrame()

{

cout<<"Size of tyre: "<<size<<endl;

cout<<"Condition of Frame: "<<condition<<endl;

cout<<"Number of tyres: "<<number<<endl;

}

};

class Tire

{

string tyreCon;

int milLeft;

public:

Tyres()

{

tyreCon="decent";

}

void setMilLeft(int m)

{

milLeft=m;

if(m>=1000 && m<=25000)

tyreCon="poor";

if(m>50000)

tyreCon="good";

}

void printTyre()

{

cout<<"Tyre condition:"<<tyreCon<<endl;

cout<<"Mileage left: "<<milLeft<<endl;

}

};

class automobile

{

Frame f;

Tire t;

double price;

bool able;

public:

void set(string tSz,string fCon, int num,int mil,double pr,bool ab)

{

f.setSize(tSz);

f.setCondition(fCon);

f.setNumber(num);

t.setMilLeft(mil);

price=pr;

able=ab;

}

void printAuto()

{

cout<<"Automobile Details"<<endl<<"-----------------------"<<endl;

f.printFrame();

t.printTyre();

cout<<"Price: $"<<price<<endl;

if(able)

cout<<"Running condition: Yes"<<endl;

else

cout<<"Running condition: No"<<endl;

}

};

int main()

{

automobile a;

a.set("midium","good",4,50000,20000,true);

a.printAuto();

}

output:

Add a comment
Know the answer?
Add Answer to:
C++ PROGRAMMING: Create a program that includes three classes called automobile, frame, and tires. Each of...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Lab 2 – Classes include the header files for the classes Overview The purpose of this...

    Lab 2 – Classes include the header files for the classes Overview The purpose of this assignment is to give you some experience writing classes in C++, including utilizing accessors and constructors to organize data properly. Description This program will represent a hypothetical car production line, which consists of a chassis (body of a vehicle) and wheels. These two components will be used to make fully functioning vehicles (just use your imagination). To that end, there are three classes you...

  • Computer Science 111 Introduction to Algorithms and Programming: Java Programming Net Beans Project #4 - Classes...

    Computer Science 111 Introduction to Algorithms and Programming: Java Programming Net Beans Project #4 - Classes and Objects (15 Points) You will create 3 new classes for this project, two will be chosen (THE TWO CHOSEN ARE TENNIS SHOE AND TREE) from the list below and one will be an entirely new class you invent. Here is the list: Cellphone Clothes JuiceDrink Book MusicBand Bike GameConsole Tree Automobile Baseball MusicPlayer Laptop TennisShoe Cartoon EnergyDrink TabletComputer RealityShow HalloweenCostume Design First Create...

  • C++ program to implement inheritance with following requirements, Classes :- Animal.cpp, bird.cpp, canine.cpp, main.cpp (to test...

    C++ program to implement inheritance with following requirements, Classes :- Animal.cpp, bird.cpp, canine.cpp, main.cpp (to test it) :- -You may need getters and setters also. 1. Declare and define an animal base class: animal stores an age (int), a unique long ID (a boolean that is true if it is alive, and a location (a pair of double). animal requires a default constructor and a 3 parameter constructor. Both constructors should set the unique ID automatically. They should also set...

  • Create this c++ program. Create to classes and name their type Account and Money. Follow the...

    Create this c++ program. Create to classes and name their type Account and Money. Follow the instruction listed below. Please read and implement instructions very carefully Money Class Requirements - Negative amounts of Money shall be stored by making both the dollars and cents negative The Money class shall have 4 constructors * A default constructor that initializes your Money object to $0.00 A constructor that takes two integers, the first for the dollars and the second for the cents...

  • FOR C++ PLEASE Create a class called "box" that has the following attributes (variables): length, width,...

    FOR C++ PLEASE Create a class called "box" that has the following attributes (variables): length, width, height (in inches), weight (in pounds), address (1 line), city, state, zip code. These variables must be private. Create setter and getter functions for each of these variables. Also create two constructors for the box class, one default constructor that takes no parameters and sets everything to default values, and one which takes parameters for all of the above. Create a calcShippingPrice function that...

  • - Classes Write a C++ program that creates a class called Date that includes three pieces...

    - Classes Write a C++ program that creates a class called Date that includes three pieces of information as data members, namely:  month (type int)  day (type int)  year (type int). Program requirements: - Provide set and a get member functions for each data member. - For the set member functions assume that the values provided for the year and day are correct, but in the setMonth member function ensure that the month value is in the...

  • JAVA PROGRAMMING PLEASE This lab has three parts: Create an ArrayList class. Create a LinkedList class....

    JAVA PROGRAMMING PLEASE This lab has three parts: Create an ArrayList class. Create a LinkedList class. Print out the results after testing each of the methods in both of the classes and solving a simple problem with them. Task 1 – ArrayList Class Create an ArrayList class. This is a class that uses an internal array, but manipulates the array so that the array can be dynamically changed. This class should contain a default and overloaded constructor, where the default...

  • Program Purpose In this program you will demonstrate your knowledge in programming OOP concepts, such as classes, encapsulation, and procedural programming concepts such as lınked lists, dynamic me...

    Program Purpose In this program you will demonstrate your knowledge in programming OOP concepts, such as classes, encapsulation, and procedural programming concepts such as lınked lists, dynamic memory allocation, pointers, recursion, and debugging Mandatory Instructions Develop a C++ object oriented solution to the Towers of Hanoi puzzle. Your solution will involve designing two classes one to represent individual Disk and another to represent the TowersOfHanoi game. TowersOfHanoi class will implement the game with three linked lists representing disks on each...

  • C# Programming Exercise and Bonus Exercise (Next Page) 1) Define a class called OrderPizza that has...

    C# Programming Exercise and Bonus Exercise (Next Page) 1) Define a class called OrderPizza that has member variables to track the type of pizza being order (either deep dish, hand tossed, or pan) along with the size (small, medium or large), type of toppings (pepperoni, cheese etc.) and the number of toppings. Create accessors for each property (ex.: type, size, type of toppings, and number of toppings). Implementation class should have a CalculateOrderPayment method to compute the total cost of...

  • write a C++ program using classes, friend functions and overloaded operators. Computer class: Design a computer...

    write a C++ program using classes, friend functions and overloaded operators. Computer class: Design a computer class (Computer) that describes a computer object. A computer has the following properties: Amount of Ram in GB (examples: 8, 16), defaults to 8. Hard drive size in GB (examples: 500, 1000), defaults to 500. Speed in GHz (examples: 1.6, 2.4), defaults to 1.6. Type (laptop, desktop), defaults to "desktop" Provide the following functions for the class: A default constructor (constructor with no parameters)...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT