Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package kostka;
- public class Kostka {
- public static void main(String[] args) {
- System.out.println("Witaj graczu, zapraszam do gry w kości");
- Player[] Table = new Player[15];
- System.out.println("Do stołu zasiada 15 graczy");
- for(int i=0; i<15; i++){
- Table[i] = new Player();
- }
- System.out.println("Gracze rzucają kościami");
- for(int i=0; i<15; i++){
- Table[i].throw1 = Table[i].draw();
- Table[i].throw2 = Table[i].draw();
- Table[i].points(Table[i].throw1, Table[i].throw2);
- }
- int[] basket = new int[2];
- System.out.println("Punktacja");
- for(int i = 0; i<15; i++){
- Table[i].show(basket);
- System.out.println("Losy gracza " + (i+1) + " to: " + basket[0] + " i " + basket[1] +
- " posiada: " + Table[i].sum + "punktów" + "średnia pkt to: ");
- }
- }
- }
- --------------------------
- package kostka;
- import java.util.Random;
- import java.util.RandomAccess;
- public class Player {
- public int throw1, throw2, sum;
- public int draw(){
- Random rand = new Random();
- int randNum = rand.nextInt(6)+1;
- return randNum;
- }
- public void points(int throw1, int throw2){
- sum = throw1+throw2;
- if (throw1 == 6 || throw2 == 6) sum+=5;
- if (throw1 == 6 && throw2 == 6) sum+=10;
- if (throw1 + throw2 == 10) sum+=3;
- }
- public void show(int[] Basket) {
- Basket[0] = throw1;
- Basket[1] = throw2;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment