Objektorientierung/Rennschnecke.java

29 lines
609 B
Java

import java.util.Random;
public class Rennschnecke
{
private String name;
private String race;
private double maxspeed;
private double way;
public void krieche(){
way += maxspeed*Math.random();
}
public double getWay(){
return this.way;
}
public String toString(){
return name + " ( " + race + " ) hat bisher " + way + "cm zurückgelegt" ;
}
public Rennschnecke(String name, String race){
this.name = name;
this.race = race;
this.maxspeed = Math.random()*5;
this.way = 0;
}
}