First develop commit. Adding all existing files.

This commit is contained in:
2014-03-14 20:12:38 +01:00
parent bf68ba4560
commit 73e62547ff
441 changed files with 247478 additions and 2 deletions

View File

@@ -0,0 +1,52 @@
package diesunddas;
public class Strecke{
enum Einheit{
m(1),
km(1e3),
cm(0.01),
mm(0.001);
private double faktor;
Einheit(){}
Einheit(double faktor){ this.faktor = faktor; }
double faktor(){ return faktor; }
}
double länge;
Einheit einheit = Einheit.m;
public Strecke(double länge){
this.länge = länge;
}
public Strecke(double länge, Einheit einheit){
this.länge = länge;
this.einheit = einheit;
}
public Strecke plus(Strecke dazu){
return new Strecke(länge+dazu.länge*dazu.einheit.faktor()/einheit.faktor(), einheit);
}
@Override
public String toString(){
return länge+" "+einheit;
}
/**
* @param args
*/
public static void main(String[] args) {
Strecke heimweg = new Strecke(10, Einheit.km);
Strecke bäcker = new Strecke(420, Einheit.m);
System.out.println(heimweg);
System.out.println(bäcker);
System.out.println(heimweg.plus(bäcker));
System.out.println(bäcker.plus(heimweg));
}
}