Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a class named Car that has the following properties: Year - The Year Property holds the cars year model Make The Make property holds

Create a class named Car that has the following properties:

Year - The Year Property holds the cars year model

Make The Make property holds the make of the car.

Speed The Speed property 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 and model and make them as arguments. These values should be assigned to the backing fields for the objects Year and Make properties. The constructor should also assign 0 to the backing field for the Speed property.

Accelerate The Accelerate method should add 5 to the Speed propertys backing field each time it is called.

Brake The Brake method should subtract 5 from the Speed propertys backing field each time it is called.

Demonstrate the class in an application that creates a Car object. The applications form should have an Accelerate button that calls the Accelerate method and then displays the cars current speed each time the button is clicked. The applications form should also have a Brake button that calls the Brake method and then displays the cars current speed each time the button is clicked.

Let the user know if they have not entered a make or year by displaying a messageBox. Show current speed in a label. Make sure the speed is never a negative number by letting the user know the car is not moving if the speed is 0.

Example of form can be as followed:

image text in transcribed

(done in c#)

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

Databases In Networked Information Systems 6th International Workshop Dnis 2010 Aizu Wakamatsu Japan March 2010 Proceedings Lncs 5999

Authors: Shinji Kikuchi ,Shelly Sachdeva ,Subhash Bhalla

2010th Edition

3642120377, 978-3642120374

More Books

Students also viewed these Databases questions