Hallo.
ich benutze:
- JavaScript
- jEdit
- Java Development Kit
Hier ist das Hauptprogramm:
public class fahrzeug {
public static void main(String[] args) {
Auto Auto1 = new Auto(8999.99, "VW Golf", 2007, 5684, "blau");
System.out.println(Auto1.getpreis());
System.out.println(Auto1.getmodell());
System.out.println(Auto1.getbaujahr());
System.out.println(Auto1.getkilometerstand());
System.out.println(Auto1.getfarbe());
System.out.println(Auto1.setpreis(8749.99));
System.out.print("Der neue Preis des Autos beträgt: " + Auto1.setpreis);
}
}
Und hier ist das Programm mit den Attributen für das Objekt, etc.:
public class Auto {
private double preis;
private String modell;
private int baujahr;
private int kilometerstand;
private String farbe;
public Auto (double wert1, String wert2, int wert3, int wert4, String wert5) {
this.preis = wert1;
this.modell = wert2;
this.baujahr = wert3;
this.kilometerstand = wert4;
this.farbe = wert5;
}
public double getpreis() {
return preis;
}
public String getmodell() {
return modell;
}
public int getbaujahr() {
return baujahr;
}
public int getkilometerstand() {
return kilometerstand;
}
public String getfarbe() {
return farbe;
}
public void setpreis() {
this.preis = wert1;
}
}
Wenn ich das Hauptprogramm nun in den Compiler eingebe, bekomme ich folgende Fehlermeldung:
fahrzeug.java:4: error: cannot find symbol
Auto Auto1 = new Auto(8999.99, "VW Golf", 2007, 5684, "blau");
^
symbol: class Auto
location: class fahrzeug
fahrzeug.java:4: error: cannot find symbol
Auto Auto1 = new Auto(8999.99, "VW Golf", 2007, 5684, "blau");
^
symbol: class Auto
location: class fahrzeug
2 errors
Kann mir bitte jemand helfen? Ich habe es eins zu eins so von meinem Buch abgeschrieben, doch es funktioniert einfach nicht.
LG