77 456
Assignments Done
Successfully Done
In July 2019

Answer to Question #7546 in Java | JSP | JSF for Janice

Question #7546
Write a main program class that instantiates a Deck and several Card
objects and calls each of their methods. The purpose of this class is to verify that
your supporting classes work correctly.
Expert's answer
Class Card
public class Card {
private String color;
private String grade;
Card(String color, String grade){
this.color = color;
this.grade = grade;
public void setColor(String color) {
this.color = color;
public void setGrade(String grade) {
this.grade = grade;
public String getColor() {
return color;
public String getGrade() {
return grade;
Class Deck
public class Deck {
private Card[] card;
Deck(Card[] card){
this.card = card;
public Card[] getCard() {
return card;
public void setCard(Card[] card) {
this.card = card;
public void showCards(){
for(Card c: card)
System.out.println("Color: "+c.getColor()+", grade: "+c.getGrade());
Main Class
public class Main{
static Card c1 = new Card("Spades","King");
static Card c2 = new Card("Hearts","Queen");
static Card[] c = {c1,c2};
static Deck deck = new Deck();
public static void main(String[] args) {

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!


No comments. Be first!

Leave a comment

Ask Your question

Privacy policy Terms and Conditions