Advertisement
ljukk

trieda k urne

May 23rd, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.78 KB | None | 0 0
  1. /**
  2.  *
  3.  * @author sused
  4.  */
  5. public class Urna {
  6.  
  7.     private final String moznosti[] = {" Moznost 1","Moznost 2","Moznost 3"};
  8.     private int hlasy[];
  9.  
  10.     public Urna() {
  11.         hlasy = new int[moznosti.length];
  12.         for (int i = 0; i < hlasy.length; i++)
  13.             hlasy[i] = 0;
  14.     }    
  15.     public void zahlasuj(int i) {
  16.         hlasy[i]++;
  17.     }
  18.     public int getHlasy(int i) {
  19.         return hlasy[i];
  20.     }
  21.    
  22.     public int getPocet() {
  23.         return moznosti.length;
  24.     }
  25.    
  26.     public String getNazov(int i) {
  27.         return moznosti[i];
  28.     }
  29.    
  30.     public String getVysledok() {
  31.      String s = "";  
  32.        for (int i = 0; i < hlasy.length; i++)
  33.            s = s + moznosti[i] + ": " + hlasy[i] + "\n ";
  34.        return s;
  35.     }
  36.    
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement