Number05Chapter10.docx

CS 313 01

Program Assignment 05 Chapter 10

20 Points

Name ___________________________________

Due: Wednesday, April 1, 2020

Create a class named Car that has the following properties:

· Year – The Year property holds the car’s year

· Make – The Make property holds the make of the car

· Speed – The Speed property holds the car’s current speed

In addition, the class should have the following constructor and other methods:

· Constructor – The constructor should accept the car’s year and model and make them as arguments. These values should be assigned to the backing fields for the object’s 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 property’s backing field each time it is called.

· Brake – The Brake method should subtract 5 from the Speed property’s backing field each time it is called

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

Add the following comments to the beginning of the program.

Name: Your Name

Class and Section: CS 313 01

Assignment: Program Assignment 05

Due Date: See above

Date Turned in:

Program Description: You write a short description of what the program will do

When you complete the program, do the following.

1. Create a folder with the following name: Program 05

2. Copy your project to this folder

3. Zip the folder

4. Send the zipped folder to my email – [email protected] – as an attachment.

Extra Credit – 5 points

Be sure that the speed does not exceed 100 and does not go below 0.