Write a class named car that has the member variables

Assignment Help Programming Languages
Reference no: EM13772227

Work on this part individually. Use the Visual Studio development environment. Open book and notes. Submit a clean copy of your code and screenshots of sample runs. No assistance.

1. Write a class named Car that has the following member variables:

· YearModel. An int that holds the car's year model

· Make. A string that holds the make of the car

 

· Speed. An int that holds the car's current speed

In addition, the class should have the following constructor and other member functions.

· A default constructor. Set all private data members to default values. Speed should be set to zero.

 

· A constructor with parameters. The constructor should accept the car's year model and make as argument. Set speed to zero.

· accessor/get. Appropriate accessor methods for the private data members.

· mutator/set. Appropriate mutator method for the private data members (as needed).

· accelerate. The accelerate method should receive an integer parameter value between 1 and 5 (inclusive) add value to the speed of the Car.

 

· break. The break method should receive an integer parameter value between 1 and 5 (inclusive) and subtract value from the speed of the Car.

 

· print . displays the value of the private data members of the class

Demonstrate the class in a program that creates a Car object, and the calls the accelerate function twice. After each call to the accelerate method, display the current speed of the car. Then call the break function two times. After each call print the speed of the car.

2. For the Car class in part 1. Write a non-member function faster() that receives two Car objects and returns the car object with the higher speed. Test this function in the main program and print the object/car with the higher speed.

3. Declare a Car pointer variable cptr and make it point to one of the car objects that was created in problem 1or 2. Use the pointer variable cptr to call the print method.

4. Use the cptr to dynamically allocate a Car object. Use the cptr to call the methods accelerate and print in the object.

5. Return the allocated memory to the system.

Reference no: EM13772227

Questions Cloud

What would the aggregate function be : I am trying to aggregate demand functions. If the two functions are Q1=150-10P and the second function is Q2=150-5P, what would the aggregate function be?
Write paper on threatned and endangere species in everglades : Write a paper about threatned and endangered species in the Everglades and the climate of the Everglades.
Limitations of confounding variables : What are controls in a research study and how are they used? How are controls used in this study?
Critique a human resource article which study employee devel : Critique a human resource article which study employee development (appraising and managing performance, training the workforce, developing careers). The critique must contain the following: -A brief introduction of the article A statement of the pro..
Write a class named car that has the member variables : Write a class named Car that has the following member variables: YearModel. An int that holds the car's year model
Who are the stakeholders in this case : Who are the stakeholders in this case? What are the interests of the stakeholders? Do any of the environmental laws from the eGuide apply to this case? If they do apply, analyze the legality of the government's actions in this case
The largest ocean feeding glaciers : What was your opinion on the documentary; do you feel that the melting glaciers are an immediate problem?
What is your favorite green product in construction : What is your favorite green product in (construction)? What are its best features? Its worst? How would you convince people to buy it? What is the price for it in Tennessee State?
Critique a human resource article which study these fields : Critique a human resource article which study these fields: work flows, job analysis, equal opportunity and the legal environment, manging diversity. The critique must contain the following: -A brief introduction of the article A statement of the pro..

Reviews

Write a Review

Programming Languages Questions & Answers

  Create a simple command line program

Create a simple command line program that simulates the rolling of a pair of six sided dice a user given number of times. The number of times to roll the pair of dice should be read as input from the argv array on the command line.

  Binary search algorithm to search an array

The binary search algorithm that follows may be used to search array when elements are in order. This algorithm is analogous to following approach for finding name in telephone book.

  Problem on java programming

I have a text file located in the same folder with some various numbers, and it won't work. Thanks in advance.

  Write program using while loop to output squares of integers

Write a program that uses while loop to perform the following steps:Output the sum of all the even numbers between firstnum and secondnum inclusive. Output all the numbers and their squares between firstnum and secondnum inclusive.

  Pseudocode program by multiplying the length by the width

An area is calculated by multiplying the length by the width. The pseudocode program below shouldask the user for the length and width of a rectangular room in order to calculate the area, and displaythe room's area. Will it do the job.

  Choose one 1 of the working groups in the ietf or ieee and

write a three to four 3-4 page paper in which youquestion 1. select one 1 of the working groups in the ietf or

  Create script which checks day of the week

Create a script which checks day of the week, and takes one of two actions (step 2 or 3) depending on the day. If day is Monday through Friday, print (send to stdout) name of the day.

  Program to assign new value to first element of array

Suppose that the ArrayList of integers named has been declared and initialized. Write single statement which assigns a new value to first element of the ArrayList.

  Estimate probability of default for a credit application

What would you suggest as the target variable and what would you recommend that Joe do to achieve his business goal?

  Function to responds- to click anywhere on page-display box

Write a function that responds to a click anywhere on the page by displaying an alert dialog. display the event name if the user held shift during the mouse click.

  Create shell script to enter length and width of rectangle

Network client needs you create the shell script which permits the user to enter length and width of rectangle. Perimeter of rectangle is then computed and printed to computer screen.

  Occurrence of the longest substring of capital

Input a string. Output the starting position and length of the first occurrence of the longest substring of capital Xs in that string. The first letter is in position 1.

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