First develop commit. Adding all existing files.
This commit is contained in:
52
srcDE/diesunddas/Würfel.java
Normal file
52
srcDE/diesunddas/Würfel.java
Normal file
@@ -0,0 +1,52 @@
|
||||
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());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user