So meine frage lautet
Schreiben Sie ein Stuck Java-Code, welches das Gesamtgewicht ihres Golfs aus Aufgabe
berechnet und in einer Variable names gewicht speichert.
meine klasse auto
class public Auto {
// Eigenschaften
private String typ;
private String hersteller;
private int sitze;
private int gewicht;
private float luftwiderstand;
private int ps;
private int kg;
// Konstruktor
public Auto(String Typ,String Hersteller, int sitze, int gewicht,
float luftwiderstand, int ps, int kg){
this.typ = typ;
this.hersteller = hersteller;
this.sitze = sitze ;
this.gewicht = gewicht;
this.luftwiderstand = luftwiderstand;
this.ps = ps;
this.kg = kg;
}
}
mein objekt golf:
Auto golf = new Auto("Golf","VW",5,200,0.35,75,1800);
so nun zur aufgabe. hab sie wie folg gelöst hoffe die ist richtig bin mir nicht sicher
int gewicht;
gewicht= auto.golf.gewicht + auto.golf.kg
System.out.println(gewicht + "kg");
danke
Schreiben Sie ein Stuck Java-Code, welches das Gesamtgewicht ihres Golfs aus Aufgabe
berechnet und in einer Variable names gewicht speichert.
meine klasse auto
class public Auto {
// Eigenschaften
private String typ;
private String hersteller;
private int sitze;
private int gewicht;
private float luftwiderstand;
private int ps;
private int kg;
// Konstruktor
public Auto(String Typ,String Hersteller, int sitze, int gewicht,
float luftwiderstand, int ps, int kg){
this.typ = typ;
this.hersteller = hersteller;
this.sitze = sitze ;
this.gewicht = gewicht;
this.luftwiderstand = luftwiderstand;
this.ps = ps;
this.kg = kg;
}
}
mein objekt golf:
Auto golf = new Auto("Golf","VW",5,200,0.35,75,1800);
so nun zur aufgabe. hab sie wie folg gelöst hoffe die ist richtig bin mir nicht sicher
int gewicht;
gewicht= auto.golf.gewicht + auto.golf.kg
System.out.println(gewicht + "kg");
danke