public class Biler {
public static void main(String[] args) {
Bil bil1 = new Bil("Volvo", 0, 2024);
bil1.godkjenne();
if (bil1.euGodkjent) {
System.out.println("Bilen er godkjent");
} else {
System.out.println("Bilen er ikke godkjent");
}
bil1.leggTilKm(200);
System.out.println("Bilen har n? " + bil1.hentKm() + " km.");
}
}
class Bil {
private String bilMerke;
private int kmStand;
private int aarsModell;
public boolean euGodkjent;
static int refNummer = 0;
public Bil(String bilMerke, int kmStand, int aarsModell) {
this.bilMerke = bilMerke;
this.kmStand = kmStand;
this.aarsModell = aarsModell;
this.euGodkjent = false;
}
public void godkjenne() {
this.euGodkjent = true;
}
public boolean erBilenGodkjent() {
return this.euGodkjent;
}
public void leggTilKm(int km) {
this.kmStand += km;
}
public int hentKm() {
return this.kmStand;
}
}