he CODE Must be in JAVA. Please show in simplest form and with comments. Please show the outputs as well (Minimum 2) public class Card{ int faceValue; int suit; Card(){ this.faceValue = 9; this.suit = 1; } Card(int f,int s){ this.faceValue = f; this.suit = s; } String getfaceValue(){ if(this.faceValue==1) return "Ace"; else if(this.faceValue==2) return "Two"; else if(this.faceValue==3) return "Three"; else if(this.faceValue==4) return "Four"; else if(this.faceValue==5) return "Five"; else if(this.faceValue==6) return "Six"; else if(this.faceValue==7) return "Seven"; else if(this.faceValue==8) return "Eight"; else if(this.faceValue==9) return "Nine"; else if(this.faceValue==10) return "Ten"; else if(this.faceValue==11) return "Jack"; else if(this.faceValue==12) return "Queen"; else if(this.faceValue==13) return "King"; else return "Inavlid"; } String getSuit(){ if(this.suit==1) return "Spades"; else if(this.suit==2) return "Hearts"; else if(this.suit==3) return "Clubs"; else if(this.suit==4) return "Diamonds"; else return "Invalid"; } void setfaceValue(int s){ this.faceValue = s; } void setSuit(int s){ this.suit=s; } public String toString(){ return getfaceValue()+" of "+getSuit(); } } //Test Driver for the Card public class TestDriver{ public static void main(String[] args) { Card c1 = new Card(1,1); System.out.println(c1); } }
The CODE Must be in JAVA. Please show in simplest form and with comments. Please show the outputs as well (Minimum 2)
public class Card{
int faceValue;
int suit;
Card(){
this.faceValue = 9;
this.suit = 1;
}
Card(int f,int s){
this.faceValue = f;
this.suit = s;
}
String getfaceValue(){
if(this.faceValue==1)
return "Ace";
else if(this.faceValue==2)
return "Two";
else if(this.faceValue==3)
return "Three";
else if(this.faceValue==4)
return "Four";
else if(this.faceValue==5)
return "Five";
else if(this.faceValue==6)
return "Six";
else if(this.faceValue==7)
return "Seven";
else if(this.faceValue==8)
return "Eight";
else if(this.faceValue==9)
return "Nine";
else if(this.faceValue==10)
return "Ten";
else if(this.faceValue==11)
return "Jack";
else if(this.faceValue==12)
return "Queen";
else if(this.faceValue==13)
return "King";
else
return "Inavlid";
}
String getSuit(){
if(this.suit==1)
return "Spades";
else if(this.suit==2)
return "Hearts";
else if(this.suit==3)
return "Clubs";
else if(this.suit==4)
return "Diamonds";
else
return "Invalid";
}
void setfaceValue(int s){
this.faceValue = s;
}
void setSuit(int s){
this.suit=s;
}
public String toString(){
return getfaceValue()+" of "+getSuit();
}
}
//Test Driver for the Card
public class TestDriver{
public static void main(String[] args) {
Card c1 = new Card(1,1);
System.out.println(c1);
}
}
Step by step
Solved in 2 steps with 2 images