Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Tarok {
- public static void main(String[] args) {
- int a=0, b=0, c=0, d=0;
- //Preberemo vhodne podatke
- System.out.println("Maksimalno stevilo partij: ");
- int steviloPartij=BranjePodatkov.preberiInt();
- System.out.println("Zgornja meja stevila tock: ");
- int zgornjaMeja=BranjePodatkov.preberiInt();
- //System.out.println("Verjetnost zmage v posamezni partiji: ");
- //double verjetnostZmage=BranjePodatkov.preberiInt();
- double verjetnostZmage=0.7;
- //Glava tabele:
- System.out.println();
- System.out.print(" "+"A");
- System.out.print(" "+"B");
- System.out.print(" "+"C");
- System.out.println(" "+"D");
- System.out.println("============================");
- System.out.print(" "+"0");
- System.out.print(" "+"0");
- System.out.print(" "+"0");
- System.out.print(" "+"0");
- System.out.println();
- for (int i=0; i<steviloPartij; i++) {
- //Tri=0, Dve=1, Ena=2, soloTri=3, soloDve=4, soloEna=5
- int tipIgre = (int)(Math.random()*6);
- //Naključno določimo razliko, večkratniki števila 5 od 0 do 35, zato število 8
- int razlika = (int) ((Math.random()*8))*5;
- //tukaj ugotovimo, če smo zmagali ali izgubili glede na dano verjetnostZmage. Če smo zmagali nastavimo zmaga na 1, drugače na 0.
- double novaVerjetnost=Math.random();
- int zmaga=0;
- if (novaVerjetnost<verjetnostZmage) {
- zmaga=1;
- }
- //naključno izberemo prvega igralca
- int prviIgralec = (int) (Math.random()*4);
- //naključno izberemo drugega igralca, ki mora ustrezati pravilom igre tarok (igri se lahko pridruži le pri tri, dve in ena).
- int drugiIgralec=44444;
- if ((tipIgre == 0) || (tipIgre == 1) || (tipIgre == 2)) {
- drugiIgralec = (int) (Math.random()*4);
- }
- //estetsko izpišemo podatke
- System.out.println(" ");
- if (tipIgre == 0) {
- System.out.print("tri");
- }
- if (tipIgre == 1) {
- System.out.print("dve");
- }
- if (tipIgre == 2) {
- System.out.print("ena");
- }
- if (tipIgre == 3) {
- System.out.print("solo tri");
- }
- if (tipIgre == 4) {
- System.out.print("solo dve");
- }
- if (tipIgre == 5) {
- System.out.print("solo ena");
- }
- System.out.print(",");
- System.out.print(" ");
- if (prviIgralec == 0) { //naključno izbran prviIgralec poimenujemo s črko, saj naloga tako zahteva.
- System.out.print("A");
- }
- if (prviIgralec == 1) {
- System.out.print("B");
- }
- if (prviIgralec == 2) {
- System.out.print("C");
- }
- if (prviIgralec == 3) {
- System.out.print("D");
- }
- if (drugiIgralec == 0) {
- System.out.print("A");
- }
- if (drugiIgralec == 1) {
- System.out.print("B");
- }
- if (drugiIgralec == 2) {
- System.out.print("C");
- }
- if (drugiIgralec == 3) {
- System.out.print("D");
- }
- System.out.print(",");
- System.out.print(" ");
- if (zmaga == 1) {
- System.out.print("+"); //če zmagamo, se nam točke prištejejo zato predznak +
- } else {
- System.out.print("-"); //če izgubimo, se nam točke zmanjšajo zato predznak -
- }
- System.out.print(razlika);
- //potrebujemo tipIgre in ga pomnožimo z 10, nato pa še prištejemo 10, da se rezultat sklada s podano tabelo,
- //če ne zmagamo so skupne točke negativne.
- int tockeZaIgro = tipIgre*10 +10;
- int skupneTocke = tockeZaIgro + razlika;
- if (zmaga==0) {
- skupneTocke=skupneTocke*(-1);
- }
- //podelimo točke, in preverimo da drugi igralec vstopa samo v igre katere sme - 0, 1 in 2
- if (prviIgralec == 0) {
- a = a + skupneTocke;
- }
- if (prviIgralec == 1) {
- b = b + skupneTocke;
- }
- if (prviIgralec == 2) {
- c = c + skupneTocke;
- }
- if (prviIgralec == 3) {
- d = d + skupneTocke;
- }
- if ((tipIgre == 0) || (tipIgre == 1) || (tipIgre == 2)) {
- }
- if (drugiIgralec == 0) {
- a = a + skupneTocke;
- }
- if (drugiIgralec == 1) {
- b = b + skupneTocke;
- }
- if (drugiIgralec == 2) {
- c = c + skupneTocke;
- }
- if (drugiIgralec == 3) {
- d = d + skupneTocke;
- }
- System.out.println();
- System.out.println(a+", "+b+", "+c+", "+d);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement