C
C#14mo ago
Ahmed

❔ ✅ It's not writing to the console that car1 is driving

Car car1 = new Car("ford", "mustang", 2022, "red");
Car car2 = new Car("idk", "idk", 2001, "idk");
Console.WriteLine();
Console.ReadLine();

car1.Drive();


class Car
{
string make;
string model;
int year;
string colour;
public static int numberOfCars;


public Car(string make, string model, int year, string colour)
{
this.make = make;
this.model = model;
this.year = year;
this.colour = colour;
numberOfCars++;
}

public void Test()
{
Console.WriteLine(numberOfCars);
}
public void Drive()
{
Console.WriteLine("You drive the " + make + " " + model);
Console.ReadLine();
}

}
Car car1 = new Car("ford", "mustang", 2022, "red");
Car car2 = new Car("idk", "idk", 2001, "idk");
Console.WriteLine();
Console.ReadLine();

car1.Drive();


class Car
{
string make;
string model;
int year;
string colour;
public static int numberOfCars;


public Car(string make, string model, int year, string colour)
{
this.make = make;
this.model = model;
this.year = year;
this.colour = colour;
numberOfCars++;
}

public void Test()
{
Console.WriteLine(numberOfCars);
}
public void Drive()
{
Console.WriteLine("You drive the " + make + " " + model);
Console.ReadLine();
}

}
3 Replies
Pobiega
Pobiega14mo ago
remove the Console.ReadLine() in your top level code
Ahmed
AhmedOP14mo ago
shoot where did that come from thank you :)) !close
Accord
Accord13mo ago
Closed! Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server