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

  Debug a simple visual basic program

The GUI program will have a button that creates a new window with the word Hello. Enhance the display by making the word change color, move, or change to another language (such as Hola).

  What will the permissions string contain

If you execute ls -ld on the project38" directory, what will the permissions string contain? If you execute ls -l on the iapp_v_8 file contained in project38 , what will the permissions string contain

  Validation case using regexp

The user must enter a valid IPV4 number in the range 0.0.0.0 to 255.255.255.255(decimal numbers). The number in each category must be between 0-255.

  Write a recursive-descent parser

Use any programming language you prefer to write a recursive-descent parser that parses the language generated by the following EBNF descriptions.

  Write function to merge contents of two sorted arrays

Write a function which will merge contents of two sorted (ascending order) arrays of type FLOAT values, use efficient bubble sort to sort two arrays first and then use merger function.

  Calculate the sum of squares of numbers using for loop

Given int variables k and total which have already been declared, use for loop to calculate the sum of squares of first 50 counting numbers, and store this value in total.

  Write a prolog relation subsequence

Write a Prolog relation remove(E,L,R) that is true if R is the list which results from removing one instance of E from list L. The relation is false if E isn't a member of L.

  Describe program which converts fahrenheit to celsius

Create the following program which converts Fahrenheit to Celsius. Your program must have the following functions: Read integer Fahrenheit temperatures from the user. You need to check whether the input is the correct one or not. If the user enters..

  Create program which lists total points scored

Create program which lists total points scored for each of 30 classrooms. Include invalid input check if a proper room number is not entered.

  Write function template that accepts array

Write a function template arraySum () whihc accepts an array and number of values stored in it and returns sum of those values.

  Design employee objects-display each object-s yearly salary

Design two employee objects and display each object's yearly salary. Then provide each employee 10% raise and display each Employee's yearly salary again.

  Assess the key practices and improvement activities from

suppose you are working as a senior software development manager in a software house. the company develops custom

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