JAVA Define a Class Card that will store the face value of the Card and the Suit
ID: 3682741 • Letter: J
Question
JAVA
Define a Class Card that will store the face value of the Card and the Suit Value Include a minimun of 5 fields: Face Value as Integer Face Value as String o Suit Value as Integer Suit Value as String Card number of 1 to 52 (or 0 to 51) Include a method to return the value of both for printing. I suggest you use toString(). Create a class for the Deck of Cards containing a set of operations that do the following: Initializes a Linked List that contains all 52 cards in order. Draws one card at a time from the Deck and removes the card from the deck. Checks to see if there are any cards in the deck. Keeps track of how many cards are left in the deck. Shuffles the deck. Print the deck for debugging purposes as you test your game. Create a class for a dealt hand of cards containing a set of operations that do the following: Initializes an empty hand of cards. Prints the hand of cards. Keeps track of how many cards are in the hand. Draws a card from the deck and pExplanation / Answer
class Payment
{
private double amount;
public Payment(){
amount = 0;
}
public Payment(double amount){
this.amount = amount;
}
public void setPayment(double amount){
this.amount = amount;
}
public double getPayment(){
return amount;
}
public void paymentDetails(){
System.out.println("The payment amount is " + amount);
}
}
class CashPayment extends Payment{
public CashPayment(){
super();
}
public CashPayment(double amt){
super(amt);
}
public void paymentDetails(){
System.out.println("The cash payment amount is "
+ getPayment());
}
}
class CreditCardPayment extends Payment{
private String name;
private String expiration;
private String creditcard;
public CreditCardPayment(){
super();
name = "";
expiration = "";
creditcard = "";
}
public CreditCardPayment(double amt, String name, String expiration, String creditcard){
super(amt);
this.name = name;
this.expiration = expiration;
this.creditcard = creditcard;
}
public void paymentDetails(){
System.out.println("The credit card payment amount is " + getPayment());
System.out.println("The name on the card is: " + name);
System.out.println("The expiration date is: " + expiration);
System.out.println("The credit card number is: " + creditcard);
}
}
class Question1Payment{
public static void main(String[] args)
{
CashPayment cash1 = new CashPayment(50.5), cash2 = new CashPayment(20.45);
CreditCardPayment credit1 = new CreditCardPayment(10.5, "Fred", "10/5/2010", "123456789");
CreditCardPayment credit2 = new CreditCardPayment(100, "Barney", "11/15/2009", "987654321");
System.out.println("Cash 1 details:");
cash1.paymentDetails();
System.out.println();
System.out.println("Cash 2 details:");
cash2.paymentDetails();
System.out.println();
System.out.println("Credit 1 details:");
credit1.paymentDetails();
System.out.println();
System.out.println("Credit 2 details:");
credit2.paymentDetails();
System.out.println();
}
}class Payment
{
private double amount;
public Payment(){
amount = 0;
}
public Payment(double amount){
this.amount = amount;
}
public void setPayment(double amount){
this.amount = amount;
}
public double getPayment(){
return amount;
}
public void paymentDetails(){
System.out.println("The payment amount is " + amount);
}
}
class CashPayment extends Payment{
public CashPayment(){
super();
}
public CashPayment(double amt){
super(amt);
}
public void paymentDetails(){
System.out.println("The cash payment amount is "
+ getPayment());
}
}
class CreditCardPayment extends Payment{
private String name;
private String expiration;
private String creditcard;
public CreditCardPayment(){
super();
name = "";
expiration = "";
creditcard = "";
}
public CreditCardPayment(double amt, String name, String expiration, String creditcard){
super(amt);
this.name = name;
this.expiration = expiration;
this.creditcard = creditcard;
}
public void paymentDetails(){
System.out.println("The credit card payment amount is " + getPayment());
System.out.println("The name on the card is: " + name);
System.out.println("The expiration date is: " + expiration);
System.out.println("The credit card number is: " + creditcard);
}
}
class Question1Payment{
public static void main(String[] args)
{
CashPayment cash1 = new CashPayment(50.5), cash2 = new CashPayment(20.45);
CreditCardPayment credit1 = new CreditCardPayment(10.5, "Fred", "10/5/2010", "123456789");
CreditCardPayment credit2 = new CreditCardPayment(100, "Barney", "11/15/2009", "987654321");
System.out.println("Cash 1 details:");
cash1.paymentDetails();
System.out.println();
System.out.println("Cash 2 details:");
cash2.paymentDetails();
System.out.println();
System.out.println("Credit 1 details:");
credit1.paymentDetails();
System.out.println();
System.out.println("Credit 2 details:");
credit2.paymentDetails();
System.out.println();
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.