Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Card {
- // Variables
- String value;
- String symbol;
- String abbreviation;
- // Constructors
- Card(){
- value = "";
- symbol = "";
- abbreviation = "";
- }
- Card(String value, String symbol){
- this.value = value;
- this.symbol = symbol;
- String abb = "";
- switch(this.symbol){
- case "heart":
- abb += "hrt";
- break;
- case "club":
- abb += "clb";
- break;
- case "diamond":
- abb += "dmd";
- break;
- case "spade":
- abb += "spd";
- break;
- default:
- abb += "notValidSymbol";
- }
- abb += value;
- this.abbreviation = abb;
- }
- // Methods
- public void showStatus(){
- System.out.println("Card's info: ");
- System.out.println("Value: " + value);
- System.out.println("Symbol: " + symbol);
- }
- public void display(){
- System.out.print(abbreviation);
- }
- // MAIN FUNCTION
- public static void main(String[] args){
- // Card myCard = new Card("K", "heart");
- // myCard.showStatus();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement