Files
wscience/srcDE/diesunddas/Würfel.java

53 lines
842 B
Java

package diesunddas;
/**
* @author Daniel Weschke
*
*/
public class Würfel{
/**
* Würfelname
*/
private int würfel = 1;
/**
* Maximale Würfelaugen / Anzahl der Flächen
*/
private int augen = 6;
public Würfel(int würfel){
this.würfel = würfel;
}
public Würfel(int würfel, int augen){
this.würfel = würfel;
this.augen = augen;
}
public int getWürfel(){
return würfel;
}
// TODO
public int add(Würfel würfel){
return wurf() + würfel.wurf();
}
public int wurf(){
return (int) (Math.random()*augen+1);
}
/**
* @param args
*/
public static void main(String[] args) {
Würfel w = new Würfel(3);
for(int i=0;i<20; i++) System.out.println(w.wurf());
System.out.println();
Würfel w2 = new Würfel(5,9);
for(int i=0;i<20; i++) System.out.println(w2.wurf());
}
}