I got stuck at this point i have no idea how to solve it. I want the class Test to make a new Auto object.
The error im getting:
constructor Auto in class Auto cannot be applied to given types;
required: no arguments
found: int,int, double
reason actual and formal argument lists differ in length
This is the Test class:
public class Test
{
Auto otto;
public Test()
{
otto = new Auto(10000, 70, 7.5);
otto.fahren(20);
otto.anzeigen();
otto.fahren(60);
otto.anzeigen();
otto.fahren(20);
otto.anzeigen();
otto.fahren(30);
otto.anzeigen();
otto.fahren(80);
otto.anzeigen();
otto.fahren(280);
otto.anzeigen();
}
}
This is the Auto class:
public class Auto
{
double kmStand;
double Tank;
double verbrauch1;
double verbrauch;
public Auto(double KmStand, double Tank, double Verbrauch)
{
kmStand = KmStand;
Tank = Tank;
verbrauch = Verbrauch;
}
// public void setkmStand(double newKmStand)
// {
// kmStand = newKmStand;
// }
// public void setTank(double newTank)
// {
// Tank = newTank;
// }
// public void setVerbrauch(double newVerbrauch)
// {
// verbrauch = newVerbrauch;
// }
public void fahren(double km)
{
kmStand += km;
verbrauch1 = km * (verbrauch/100);
Tank -= verbrauch1;
}
public void anzeigen()
{
System.out.println("Ihr Kilometerstand beträgt " + kmStand + " km.");
System.out.println("Ihr Benzinstand beträgt " + Tank + " Liter.");
System.out.println("Ihr Verbrauch beträgt " + verbrauch + "Liter/100 km.");
}
}
would appreciate any help