Commit c380ee0c authored by mahoffmann's avatar mahoffmann
Browse files

Übung OOP 1-2 - added Würfel

parent 28a3cb70
......@@ -2,14 +2,18 @@ package games.bin;
import games.rolldice.Dice;
public class Program {
public class Program extends Dice {
public static void main(String[]args){
public static void main(String[] args) {
Dice dice = new Dice();
dice.rollDice();
dice.showHistory();
}
}
......@@ -4,17 +4,36 @@ import java.util.Random;
public class Dice {
private int pips;
protected int counter = 0;
Random roll = new Random();
double[] rollHistory = new double[100_000];
protected double[] rollHistory = new double[1_000_000];
public Dice(){
/**
* Konstruktor für Objekt Würfel
*/
public Dice() {
pips = 6;
}
public void rollDice(){
pips = 1 + roll.nextInt(6);
System.out.println(pips);
/**
* Methode um den Würfel 1.000 x zu werfen
*/
public void rollDice() {
for (int i = 0; i <= 100; i++) {
pips = 1 + roll.nextInt(6);
rollHistory[counter] = pips;
counter++;
}
}
public void showHistory() {
for (int i = 0; i <= counter; i++) {
System.out.println("Wurf #" + i + " mit dem Wert: " + rollHistory[i]);
}
}
}
......@@ -28,8 +28,8 @@ public class Programm {
* - Alle Medien zurückgeben
*/
//videothek.lendFirstThreeMedia();
videothek.lendLastThreeMedia();
videothek.lendFirstThreeMedia();
//videothek.lendLastThreeMedia();
//videothek.lendAllMedia();
//videothek.returnAllMedia();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment