Answered step by step
Verified Expert Solution
Question
1 Approved Answer
write a c# program to simulate the functions of a car. To start, use flowcharting the logic. Used the attached diagram as a guide as
write a c# program to simulate the functions of a car. To start, use flowcharting the logic. Used the attached diagram as a guide as to what functions a car has.
Rules (These will be needed for coding purposes) SEAT BELT BUTTON The seat Belt Button will change color from RED (disconnected, default) to GREEN (Connected). Pressing the Seatbelt button when already connected will disconnect the Button (Turn it Red). KEYS Keys to the car must be dragged to the ignition switch. Trying to drag the keys with the seat belt disconnected will result in an error message and the drag operation will not work until the seat belts are connected. Once the Drag operation is completed, the Start Button will be enabled. START BUTTON The start button starts off as Disabled and is enabled once the keys are dragged to the ignition. This prohibits anyone from starting the car unless the seatbelt is on and keys are in the ignition. SPEEDOMETER The Speed of the car will be shown in three different formats. Images of the needles pointing to different speeds will mirror the digital readout. The digital readout will also be converted from MPH to KPH. When the speed of the car is greater than 55MPH, the Color of the digital readout will change to RED (both MPH and KPH) and a Speeding message will appear on the screen. When the car drops back to 55 MPH or less, the color will return to its default color. At each 10MPH, the image will change to reflect the new speed. Multiple images of different speeds will be saved and we will use a SELECT CASE statement to determine the correct image to display. GEAR SHIFT Gears cannot be changed unless the car is Started. - Error message if attempted. Gears cannot be changed unless the car is at 0MPH Error message if attempted. When the Gear is shifted to DRIVE or REVERSE, the Gas Pedal is Enabled. When the Gear is shifted to PARK or NEUTRAL, the Gas Pedal is Disabled. WIPCRS DUTTON The Wipers Button will change color from RED (not on, default) to GREEN (Wipers on). Pressing the Wipers button when already on will turn the wipers off (Turn it Red). HORN BUTTON The Hom button can have any sound of your choice. This can be a .WAV, .MP3, .CDA file. STEREO SYSTEM We will link to two different internet radio stations, as well as play .mp3 (or .WAV or .CDA files). CLOCK Not Pictured. We will incorporate a clock onto the Dashboard. TURN SIGNALS (Added) These will blink when clicked. Clicking on the LEFT turn signal will turn the RIGHT turn signal off, if it's on. Clicking on the RIGHT turn signal will turn the LEFT turn signal off, if it's on. LIGHTS The Lights button will change color from GRAY (off, default) to (ON). Pressing the Lights button when already on will turn the lights off. Pressing the Brights button will intensify the lights, if the lights are on. Pressing the foG Lights button will turn the lights into an AMBER color, if the lights are on. THE CAR The Car will move forward (left to right) and backward (right to left) across the screen. When the Car reaches the edge of the screen, it will completely disappear and reappear on the other side. This will happen both in forward and reverse gears. THE ODOMETER As the Car moves forward (left to right) across the screen, the Odometer will register 1 mile driven for each time the car reaches the edge of the screen and disappear. The Odometer will NOT go backwards If the car is in reverse. THE BRAKE The Car will slow by 10MPH each time the Brake button is pressed. If the Brake button is pressed when the car is at 0MPH, an Error Message will alert the user that the car is already stopped. The Speedometer can NEVER read 5MPH. THE GAS The Gas Pedal only works if the Car is in DRIVE or REVERSE. The Gas Pedal starts off as DISABLED - it is only enabled when the user shifts to DRIVE or REVERSE. The Gas Pedal will be used to control the SPEEDOMETER. Each time the Gas Pedal is pressed, the Speedometer will increase by 5MPH and the car will move across the screen. The car's speed will be relative to how fast it moves across the screen. The Gas Pedal will be used to decide if the user is SPEEDING (see SPEEDOMETER above). The Gas Pedal will be used to control the location of the Car on the screen and also be used to update the ODOMETER (See ODOMETER above). THE GAS TANK The Gas tank will start off as FULL and decrease by 1% each time the car moves across the screen. A Visual Basic Progress Bar will be used to decrease the value of the Bar each time the car moves off the screen. THE GAS PUMP (Not Shown) The Gas Pump will, when pressed, fill the Gas Tank (Progress Bar) to 100%. STOP The Stop Sign will End the program. Rules (These will be needed for coding purposes) SEAT BELT BUTTON The seat Belt Button will change color from RED (disconnected, default) to GREEN (Connected). Pressing the Seatbelt button when already connected will disconnect the Button (Turn it Red). KEYS Keys to the car must be dragged to the ignition switch. Trying to drag the keys with the seat belt disconnected will result in an error message and the drag operation will not work until the seat belts are connected. Once the Drag operation is completed, the Start Button will be enabled. START BUTTON The start button starts off as Disabled and is enabled once the keys are dragged to the ignition. This prohibits anyone from starting the car unless the seatbelt is on and keys are in the ignition. SPEEDOMETER The Speed of the car will be shown in three different formats. Images of the needles pointing to different speeds will mirror the digital readout. The digital readout will also be converted from MPH to KPH. When the speed of the car is greater than 55MPH, the Color of the digital readout will change to RED (both MPH and KPH) and a Speeding message will appear on the screen. When the car drops back to 55 MPH or less, the color will return to its default color. At each 10MPH, the image will change to reflect the new speed. Multiple images of different speeds will be saved and we will use a SELECT CASE statement to determine the correct image to display. GEAR SHIFT Gears cannot be changed unless the car is Started. - Error message if attempted. Gears cannot be changed unless the car is at 0MPH Error message if attempted. When the Gear is shifted to DRIVE or REVERSE, the Gas Pedal is Enabled. When the Gear is shifted to PARK or NEUTRAL, the Gas Pedal is Disabled. WIPCRS DUTTON The Wipers Button will change color from RED (not on, default) to GREEN (Wipers on). Pressing the Wipers button when already on will turn the wipers off (Turn it Red). HORN BUTTON The Hom button can have any sound of your choice. This can be a .WAV, .MP3, .CDA file. STEREO SYSTEM We will link to two different internet radio stations, as well as play .mp3 (or .WAV or .CDA files). CLOCK Not Pictured. We will incorporate a clock onto the Dashboard. TURN SIGNALS (Added) These will blink when clicked. Clicking on the LEFT turn signal will turn the RIGHT turn signal off, if it's on. Clicking on the RIGHT turn signal will turn the LEFT turn signal off, if it's on. LIGHTS The Lights button will change color from GRAY (off, default) to (ON). Pressing the Lights button when already on will turn the lights off. Pressing the Brights button will intensify the lights, if the lights are on. Pressing the foG Lights button will turn the lights into an AMBER color, if the lights are on. THE CAR The Car will move forward (left to right) and backward (right to left) across the screen. When the Car reaches the edge of the screen, it will completely disappear and reappear on the other side. This will happen both in forward and reverse gears. THE ODOMETER As the Car moves forward (left to right) across the screen, the Odometer will register 1 mile driven for each time the car reaches the edge of the screen and disappear. The Odometer will NOT go backwards If the car is in reverse. THE BRAKE The Car will slow by 10MPH each time the Brake button is pressed. If the Brake button is pressed when the car is at 0MPH, an Error Message will alert the user that the car is already stopped. The Speedometer can NEVER read 5MPH. THE GAS The Gas Pedal only works if the Car is in DRIVE or REVERSE. The Gas Pedal starts off as DISABLED - it is only enabled when the user shifts to DRIVE or REVERSE. The Gas Pedal will be used to control the SPEEDOMETER. Each time the Gas Pedal is pressed, the Speedometer will increase by 5MPH and the car will move across the screen. The car's speed will be relative to how fast it moves across the screen. The Gas Pedal will be used to decide if the user is SPEEDING (see SPEEDOMETER above). The Gas Pedal will be used to control the location of the Car on the screen and also be used to update the ODOMETER (See ODOMETER above). THE GAS TANK The Gas tank will start off as FULL and decrease by 1% each time the car moves across the screen. A Visual Basic Progress Bar will be used to decrease the value of the Bar each time the car moves off the screen. THE GAS PUMP (Not Shown) The Gas Pump will, when pressed, fill the Gas Tank (Progress Bar) to 100%. STOP The Stop Sign will End the program
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started