Advertisement
mmayoub

Bagrut 2016, ex 06

Sep 26th, 2017
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.89 KB | None | 0 0
  1. Deck.java
  2. ---------
  3.  
  4. public class Deck {
  5.     private Card[][] allCards;
  6.     private Card[] myCards;
  7.  
  8.     public Deck() {
  9.         allCards = new Card[4][13];
  10.         myCards = new Card[52];
  11.     }
  12.  
  13.     public void insert(Card card) {
  14.     }
  15.  
  16.     public boolean move() {
  17.         return false;
  18.     }
  19.  
  20.     public int sum() {
  21.         int sum = 0;
  22.         for (int i = 0; i < myCards.length && myCards[i] != null; i += 1) {
  23.             sum += myCards[i].getValue();
  24.         }
  25.         return sum;
  26.     }
  27.  
  28. }
  29.  
  30.  
  31. Tester.java
  32. -----------
  33.  
  34. public class Tester {
  35.     public static boolean game(Card[] cards) {
  36.         Deck myDeck = new Deck();
  37.  
  38.         // step 1
  39.         for (Card item : cards) {
  40.             myDeck.insert(item);
  41.         }
  42.  
  43.         // step 2
  44.         while (myDeck.move()) {
  45.         }
  46.         ;
  47.  
  48.         // check win
  49.         return (myDeck.sum() % 100 == 0);
  50.     }
  51.  
  52.     public static void main(String[] args) {
  53.         Card[] cards;
  54.         // cards = .. . ..
  55.         if (game(cards)) {
  56.             System.out.println("You win!");
  57.         }
  58.     }
  59.  
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement