Advertisement
Foxxything

Untitled

Nov 25th, 2022 (edited)
846
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.28 KB | None | 0 0
  1. package Foxx;
  2.  
  3. /*
  4.  * Card - Models a card
  5.  *
  6.  * @author Foxx Azalea Pinkerton
  7.  * @since Nov 25, 2022
  8.  */
  9. public class Card {
  10.  
  11.   public Sutes sute;
  12.   public int number;
  13.   public String path;
  14.   public String type;
  15.  
  16.   /**
  17.    * Constructor for the Card class
  18.    *
  19.    * @param sute
  20.    * @param number
  21.    * @param path
  22.    */
  23.   public Card(Sutes sute, int number, String path) {
  24.     this.sute = sute;
  25.     this.number = number;
  26.     this.path = path;
  27.  
  28.     this.type = switch (number) {
  29.       case 1 -> "Ace";
  30.       case 11 -> "Jack";
  31.       case 12 -> "Queen";
  32.       case 13 -> "King";
  33.       default -> Integer.toString(number);
  34.     };
  35.   }
  36.  
  37.   /**
  38.    * Forms the message to show the card
  39.    * @return the formatted string
  40.    */
  41.   public String makeMessage() {
  42.     String number = (this.number == 0) ? "Back of Card" : Integer.toString(this.number);
  43.     String sute = (this.sute == null) ? "Back of Card" : this.sute.toString();
  44.     String type = (this.type == null) ? "Back of Card" : this.type;
  45.     String index = (this.number == 0) ? "0" : Integer.toString(this.number + (this.sute.ordinal() * 13));
  46.  
  47.     return "Card to Display: " + index + "\n" +
  48.            "Sute: " + sute + "\n" +
  49.            "Number: " + number + "\n" +
  50.            "Type: " + type + "\n";
  51.   }
  52.  
  53. }
  54.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement