Second time posting please answer this question!!! Thankyou!!
Please do it in visual studio C # and post copy of form.cs and designer.cs. Will give vgood review!!!
In this module you learned about Classes and Multiforms.
You will be completing one program for this module
Write a class named Car that has the following member variables:
In addition, the class should have the following constructor and other methods.
Demonstrate the class in a program that creates a Car object, and then calls the accelerate function five times. After each call to the accelerate function, get the current speed of the car and display it. Then, call the brake function five times. After each call to the brake function, get the current speed of the car and display it.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
namespace MyCar
{
class Car
{
private int year;
private string make;
private int speed;
// constructor
public Car()
{
this.year = 0;
this.make = "";
this.speed = 0;
}
// constructor
public Car(int year, string make)
{
this.year = year;
this.make = make;
this.speed = 0;
}
// add 5 to the speed member variable
public void accelerate()
{
// speed should not go above 120
if( this.speed < 120 )
this.speed += 5;
}
public void brake()
{
// speed should not go below 0
if( this.speed > 0 )
this.speed -= 5;
}
// getter method
public int getSpeed()
{
return this.speed;
}
public string getMake()
{
return this.make;
}
public int getYear()
{
return this.year;
}
}
public class TestCar
{
public static void Main(string[] args)
{
Car ob = new Car(2018, "Tata Harrier");
Console.WriteLine("Speed : " + ob.getSpeed());
ob.accelerate();
Console.WriteLine("Speed : " + ob.getSpeed());
ob.accelerate();
Console.WriteLine("Speed : " + ob.getSpeed());
ob.accelerate();
Console.WriteLine("Speed : " + ob.getSpeed());
ob.accelerate();
Console.WriteLine("Speed : " + ob.getSpeed());
ob.accelerate();
Console.WriteLine("Speed : " + ob.getSpeed());
ob.brake();
Console.WriteLine("Speed : " + ob.getSpeed());
ob.brake();
Console.WriteLine("Speed : " + ob.getSpeed());
ob.brake();
Console.WriteLine("Speed : " + ob.getSpeed());
ob.brake();
Console.WriteLine("Speed : " + ob.getSpeed());
ob.brake();
Console.WriteLine("Speed : " + ob.getSpeed());
}
}
}
Sample Output

Second time posting please answer this question!!! Thankyou!! Please do it in visual studio C #...
C++ Program 1a. Purpose Practice the creation and use of a Class 1b. Procedure Write a class named Car that has the following member variables: year. An int that holds the car’s model year. make. A string object 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 member functions. Constructor. The constructor should accept the car’s year and make as arguments and assign these values...
Car Class Background: Write a class named Car that will be used to store information and control the acceleration and brake of a car. Functionality: 1. Write a class named "Car” that has the following member variables: • year Model - 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 2. In addition the class should have the following member...
python Design a class named Car that has the following fields: yearModel: The yearModel field is an Integer that holds the car’s 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 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 model and make as arguments. These values should be...
Java Program Write a class named Car that has the following fields: yearModel- The yearModel field is an int that holds the car’s year model. make- The make field is a String object that holds the make of the car, such as “Ford”, “Chevrolet”, etc. speed- This speed field is an int that holds the car’s current speed. In addition, the class should have the following methods: Constructor- The constructor should accept the car’s year model and make as arguments....
In Python Programming: Write a class named Car that has the following data attributes: _ _year_model (for the car’s year model) _ _make (for the make of the car) _ _speed (for the car’s current speed) The Car class should have an _ _init_ _ method that accepts the car’s year model and make as arguments. These values should be assigned to the object’s _ _year_model and _ _make data attributes. It should also assign 0 to the _ _speed...
Car class Question Design a class named car that has the following fields: YearModel: The yearModel field is an integer that holds the car's 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 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 model and make as arguments. The values...
java Write a class named Car that has the following fields: • yearModel: The yearModel field is an int that holds the car's year model. • make: The make field is a String object that holds the make of the car. • speed: The speed field is an int that holds the car's current speed. In addition, the class should have the following methods: • Constructor: The constructor should accept the car's year model and make as arguments. These values...
(C++)This is the problem that I'm supposed to write a
program for:
This is the layout that we are supposed to fill out for the
project:
If anything is unclear, comment and I'll try to
clarify. Thank you!
Objective Reading Dala Files Project This is a variation of ng challenge 133 de Write a class named Car that has the following pelvate member variables. model Year An ie car's uodd year. make A string that bolds the make of the...
In this module you learned about Object-Oriented programming in C++ and how to combine this approach with the concepts covered in previous modules For this assignment you will write a class called Dog that has the following member variables: birthyear. An int that holds the dog’s birth year. breed. A string that holds the breed of dog. vaccines. A Boolean holding a yes/no value indicating whether the dog is currently on vaccinations. In addition, the class should have the following...
C++ Programing In this exercise, you will design a class memberType. The class has the following data members: memberName. A string that holds the name of a person memberID. A string that holds the member identification number numBooks. An int that holds the number of books bought purchaseAmt. A double that holds the amount spent on books In addition, the class should have the following constructor and other member functions. Constructor. The constructor should accept the person’s name and member...