Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Card
- {
- private String face;
- private String suit;
- /**
- Constructor: splits up input
- @param card input from commandline
- */
- public Card(String card)
- {
- //what about lowercase or mixed input?
- if(card.length()==2)
- {
- face = card.substring(0,1);
- suit = card.substring(1,2);
- }
- else
- {
- face = card.substring(0,2);
- suit = card.substring(2,3);
- }
- }
- /**
- Accessor: parses up input
- @return "face" of "suit"
- */
- public String getDescription()
- {
- String temp = "";
- if(face.equals("2")){temp+="Two";}
- if(face.equals("3")){temp+="Three";}
- if(face.equals("4")){temp+="Four";}
- if(face.equals("5")){temp+="Five";}
- if(face.equals("6")){temp+="Six";}
- if(face.equals("7")){temp+="Seven";}
- if(face.equals("8")){temp+="Eight";}
- if(face.equals("9")){temp+="Nine";}
- if(face.equals("10")){temp+="Ten";}
- if(face.equals("J")){temp+="Jack";}
- if(face.equals("Q")){temp+="Queen";}
- if(face.equals("K")){temp+="King";}
- if(face.equals("A")){temp+="Ace";}
- if(suit.equals("H")){temp+=" of Hearts";}
- if(suit.equals("D")){temp+=" of Diamonds";}
- if(suit.equals("C")){temp+=" of Clubs";}
- if(suit.equals("S")){temp+=" of Spades";}
- return temp;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement