HELP!

stephwazzy

New member
Joined
Jun 26, 2019
Messages
2
Programming Experience
Beginner
I am just beginning to learn programming and I am a bit stuck on how this code should look in Visual Studio. Please help! Seeing this solved as an example would help me with future object oriented programming!

  • Create a project and add a class called Vehicle. In your project, select Add -> New Class. You should now have a file called Vehicle.cs.

  • Add four properties to your class: color, make, model, speed. color,make, and model should be string properties. speed should be an int.
Here is code for a class with the property color:
class Vehicle
{
public string color;

}

  • Add a method called Describe(). Describe should output all of the properties of your class. Here is an example for Describe() that only outputs color:
public string Describe ()
{
return "This car is " + color;
}
  • Here is example output:
  • The Ford Focus is blue and is going 35 MPH.

  • Add two methods. speedUp() and slowdown(). speedUp() should increment the value of the speed property. slowDown() should decrement the value of the speed property.

  • Add a class called Car. Modify the class header for Car, so that it inherits from Vehicle:
class Car : Vehicle

  • Add the following code to your Main method. Paste in your output below.
  • Car myCar1 = new Car();
  • myCar1.make = “Ford”;
  • myCar1.model = “Focus”;
  • myCar1.color = “blue”;

  • Car myCar 2 = new Car();
  • myCar1.make = “Chevy”;
  • myCar1.model = “Cruze”;
  • myCar1.color = “red”;

  • for (int i = 0; i < 35; i++) {
  • myCar2.speedUp();
  • myCar1.speedUp();
  • myCar 2.speedUp();
  • }
  • for (int i =0; i < 10; i++) {
  • myCar2.slowDown();
  • }
  • myCar1.Describe();
  • myCar2.Describe();
 
If you followed the step by step instructions above, you would actually learn.
 
Firstly, please provide descriptive titles for your threads. Everyone who posts here wants help so titles like that are as much use as no title at all.

Secondly, whatever you're reading is giving you slightly poor advice because that example is afield, not a property. For this purpose, they are pretty much the same thing but there are important differences that will matter later.

As for the problem, how about you actually give it a go and then we can help you if you actually encounter an issue along the way. You don;t know whether you can do something or not if you don't even try. For instance, they've shown you how to declare one field in a class. Are you really saying that you can't copy and paste that three times and change name and possibly type for each one? You say that you'll learn from our example but you seem not to have learned from the one you already have. Doing is always the best way to learn and you can often do more than you think. There's nothing wrong with failing either, as it helps you learn what not to do. You try and, if you fail, then you ask us for help.
 
Already been answered but thanks for your two cents
If you determined the solution yourself or it was answered elsewhere, the thing to do is to provide the solution rather than deleting the question. That way, others may benefit from it later. It also means that, if your solution is not the best it can be, others can suggest improvements. It may seem like we're being critical and we are, but the intent is not to be nasty. Rather, we just want the forums to work the best they can for you, us and everyone else and there are certain things that you need to do differently for that to happen. No one enjoys being criticised but how can you ever stop doing the wrong thing and improve for your own sake and the sake of others if you never know that you're doing the wrong thing in the first place?
 
Back
Top Bottom