PlayingCard.java

package hw17; public class PlayingCard { private int value; private int suit; public PlayingCard() { value = (int)(Math.random()*13+1); suit = (int)(Math.random()*4+1); } public PlayingCard(int v, int s) { this.value =v; this.suit =s; } public String toString() { String s; switch(this.value) { case 1: s= "Ace"; break; case 2: s= "2"; break; case 3: s= "3"; break; case 4: s= "4"; break; case 5: s= "5"; break; case 6: s= "6"; break; case 7: s= "7"; break; case 8: s= "8"; break; case 9: s= "9"; break; case 10: s= " 10"; break; case 11: s= "J"; break; case 12: s="Q"; break; case 13: s= "K" ; break; default: s = "invalid value"; break; } switch(this.suit){ case 1: s = s + " of Clubs"; break; case 2: s= s + " of Diamonds"; break; case 3: s =s + " of Hearts"; break; case 4: s=s + " of Spades"; break; default: s = s + "of " +" invalid number"; break; } return s; } public int getValue() { return this.value; } public int getSuit() { return this.suit; } }