Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Foxx;
- /*
- * Card - Models a card
- *
- * @author Foxx Azalea Pinkerton
- * @since Nov 25, 2022
- */
- public class Card {
- public Sutes sute;
- public int number;
- public String path;
- public String type;
- /**
- * Constructor for the Card class
- *
- * @param sute
- * @param number
- * @param path
- */
- public Card(Sutes sute, int number, String path) {
- this.sute = sute;
- this.number = number;
- this.path = path;
- this.type = switch (number) {
- case 1 -> "Ace";
- case 11 -> "Jack";
- case 12 -> "Queen";
- case 13 -> "King";
- default -> Integer.toString(number);
- };
- }
- /**
- * Forms the message to show the card
- * @return the formatted string
- */
- public String makeMessage() {
- String number = (this.number == 0) ? "Back of Card" : Integer.toString(this.number);
- String sute = (this.sute == null) ? "Back of Card" : this.sute.toString();
- String type = (this.type == null) ? "Back of Card" : this.type;
- String index = (this.number == 0) ? "0" : Integer.toString(this.number + (this.sute.ordinal() * 13));
- return "Card to Display: " + index + "\n" +
- "Sute: " + sute + "\n" +
- "Number: " + number + "\n" +
- "Type: " + type + "\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement