Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In pseudocode design a class named Car that has the following fields: ? yearModel: The yearModel field is an Integer that holds the cars year

In pseudocode design a class named Car that has the following fields: ? yearModel: The yearModel field is an Integer that holds the cars year model. ? make: The make field references a String that holds the make of the car. ? speed: The speed field is an Integer that holds the cars current speed. In addition, the class should have the following constructor and other methods: ? Constructor: The constructor should accept the cars year model and make as arguments. These values should be assigned to the objects yearModel and make fields. The constructor should also assign 0 to the speed field. ? Accessors: Design appropriate accessor methods to get the values stored in an objects yearModel, make, and speed fields. ? accelerate: The accelerate method should add 5 to the speed field each time it is called.

? brake: The brake method should subtract 5 from the speed field each time it is called.

Next, design a program that creates a Car object, and then calls the accelerate method five times. After each call to the accelerate method, get the current speed of the car and display it. Then call the brake method five times. After each call to the brake method, get the current speed of the car and display it.

It's one code, but has to be broken up into parts:

1) Create the beginning of the definition of the Car class and fields.

2) Create the constructor for the Car class according to the textbook specifications.

3) Create the accessor functions for all the fields in the Car class.

4) Create the accelerate method for the Car class. Remember the accelerate method only increases the value of the cars speed field and is not passed any parameters or return any value!

5) Create the brake method for the Car class. Remember the brake method only decreases the value of the cars speed field and is not passed any parameters or return any value!

6) Complete the UML diagram for the Car class that includes the methods you have written. Be sure to include data types, parameters, and access specification notation.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Computer Aided Database Design

Authors: Antonio Albano, Valeria De Antonellis, A. Di Leva

1st Edition

0444877355, 978-0444877352

More Books

Students also viewed these Databases questions