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.
1
Expert's answer
2012-03-22T09:27:33-0400
Class Card public class Card { private String color; private String grade; Card(){ } 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(){ } 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) { deck.setCard(c); deck.showCards(); } }
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
Leave a comment