All pastes #339171 Raw Edit

Stuff

public text v1 · immutable
·published 2007-02-03 22:22 UTC
rendered paste body
public class Uppgift8{
    public static void main(){
        // skapa en tärning
        Dice dice = new Dice();
    }
}
        class Dice {
            //instansvariabel
            private int dots;
        
            //konstruktorer
            public Dice() {
            dots = 6;
            }
            public Dice(int d) {
            if (d <= 6 && d >= 1)
            dots = d;
            }
        
            //metoder
            public int getDots(){
                return dots;
            }
            public void rollDice(){
                dots = (int)(Math.random()*6) +1;  
            }
            }