Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help on these 2 method the deal method in the deck class and the toString class also in deck class. Current file: Card.java

I need help on these 2 method the deal method in the deck class and the toString class also in deck class.
image text in transcribed
image text in transcribed
Current file: Card.java 1 // You Card Class gets uploaded 2 public class Card 3 { 4 private String suit; 5 private int rank; 6 7 public Card(String suit, int rank) 8 this.suit = suit; 9 this.rank rank; 10 } 11 12 public boolean equals(Card otherCard) { 13 return rank othercard.getRank(); 14 } 15 16 public int compareTo(Card othercard) { 17 return rank othercard.getRank(); 18 } 19 20 public int getRank() { 21 return rank; 22 3 23 24 public String getsuit() { 25 return suit; 26 3 27 28 public String tostring() { 29 return rankToString() + "of" + suit; 30 3 31 32 public String rankToString() { 33 if (rank - 14) 34 return "Ace"; else if (rank 11) 36 return "Jack"; 37 else if (rank == 12) 38 return "Queen"; 39 else if (rank 13) 48 return "king": 41 else 42 return + rank; 43 44 35 public Deck) reset(); 3 public void reset() { string arra ("Spades", "Hearts", "Diamonds", "Clubs"}} for (int j = 0; j 0) { return false; } else { return true; 3 I 32 33 34 35 36 37 38 39 public int size int size = cards.size(); return size; 42 43 44 45 46 47 48 49 50 51 52 53 54 55 -56 / deal : If the deck is not empty (use the isEmpty method), then remove and return the last card in the deck (ArrayList) * @return a card object from the deck, null if the deck is empty. // FIXME **** MISSING CODE **** public object deal() { if (isEmpty == false) { cards.remove(cards.size() 1); return cards.get(cards.size() - 1); Jelse { return null; } / tostring Returns a string of all the cards in the deck. One card per line. Use the tostring method for the card object to do this: @return a string 59 60 61 // FIXME **** MISSING CODE **** public String tostring() { nature

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Access Patterns Database Interactions In Object Oriented Applications

Authors: Clifton Nock

1st Edition

0321555627, 978-0321555625

More Books

Students also viewed these Databases questions

Question

What is the difference between Needs and GAP Analyses?

Answered: 1 week ago

Question

What are ERP suites? Are HCMSs part of ERPs?

Answered: 1 week ago