I have made this function where I can change the price of a car if it has not already been but I cannot understand why this still works when if sold is already set as true.
public void changeThePrice(int newPrice)
{
if (sold == false)
{
price = newPrice;
}
else
{System.out.println("This car has already been sold to");
}
}
Aucun commentaire:
Enregistrer un commentaire