Need help building classes with constructors, properties, methods etc

This is not a project or solution or anything but I’m trying to learn how to build classes with constructors, properties, methods etc. This is what I have so far to start with but I feel like I need little more in the Vehicle class to make this class a little more complete. If someone could assist me on what I need to add to this class from what I have now.

Vehicle class

public class Vehicle
    {

        private int wins = 0;
        private int loses = 0;

        /// <summary>
        /// Constructor takes one argument for name.
        /// </summary>
        /// <param name="name"></param>
        public Vehicle(string name)
        {
            Name = name;
        }

        /// Property that has type driver, driver represents the driver of the vehicle.
        public string Name { get; set; }

        /// <summary>
        /// Public method named StartRace. Returns void, takes integer. Starts race when called.
        /// </summary>
        /// <param name="laps"></param>
        public void StartRace(int laps)
        {
            /// Winner gets to more than 200 laps, if not you lose.
            if (laps > 200)
                wins++;
            else
                loses++;

        }
    }

Driver class

namespace RaceTrack
{
    /// <summary>
    ///Driver is class type. This driver will drive vehicle.
    /// </summary>
    public class Driver
    {

        public int Id { get; set; }
        public string Name { get; set; }
    }
}

What can I add to the Vehicle class besides what I already have?

Don’t really know what you’re making… is it a video game? Simulation? 

Anyway, I’d recommend _against _having the StartRace() function be tied to an individual vehicle.

You should make a seperate Race class and have it keep track of all the vehicles. (Assuming there’s some competitive racing going on, but even if it’s not, it’s s good idea to keep everything contained in a reliable class)

Also you should have a co-dependent Driver<->Vehicle relationship. They need references to each other. Would the driver have any stats that would impact his racing ability?

And would the vehicle have any stats to affect the outcome of its victory? If you’re making a real-time game, you’ll also want to keep track of its position and velocity.

It’s not really anything. It’s basically to learn how to build a much more efficient class structure with object oriented structure using methods, properties, etc. I am sort of new to this language and just need assistance on how to structure what I have. More like enhancements if necessary. It’s not something I want to go deep into but for example how can I make the method for StartRace a little bit better? Do I need more than one method? Stuff like that.

The things you suggested are helpful. What would that look like as far as the code?

@gavynbryan wrote:

Don’t really know what you’re making… is it a video game? Simulation? 

 

Anyway, I’d recommend _against _having the StartRace() function be tied to an individual vehicle.

 

You should make a seperate Race class and have it keep track of all the vehicles. (Assuming there’s some competitive racing going on, but even if it’s not, it’s s good idea to keep everything contained in a reliable class)

 

Also you should have a co-dependent Driver<->Vehicle relationship. They need references to each other. Would the driver have any stats that would impact his racing ability?

 

And would the vehicle have any stats to affect the outcome of its victory? If you’re making a real-time game, you’ll also want to keep track of its position and velocity.

Hopefully you are still around. As I said this sounds like what I would want to do but how do I develop this. Do you have any examples to show of what this code would look like.

Thanks

Anyone with any coding ideas to help.  I would appreciate it.

What goes in the Vehicle class is very dependent on what you’re building.

For a car dealer, the Vehicle class might include new/used, mileage, base price, sticker price, days on the lot, driver history, etc.

For a car owner, the class might include the last oil change date, the date/mileage for the next oil change, last maintainence done, etc.

In a race game, the class might include when a scheduled pit stop will be required (tire wear, fuel), if the vehicle is damaged (needs a pit stop ASAP).