Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Change the getNumber method to return a String. We want it to return Ace, if it's a 1. 2-10 (as a String) if it's

image text in transcribed
image text in transcribed1. Change the getNumber method to return a String. We want it to return "Ace", if it's a 1. 2-10 (as a String) if it's a 2-10, "Jack" for 11, "Queen" for 12 and "King" for 13. You should not change the type of the instance variable number. Simply rewrite getNumber function to calculate appropriate String. there is a statuc method Integer.toString()
2. aAdd a method isFaceUp that doesn't have any parameters and returns true if the card is face up and fase if face down
3. add a method called flip that chanhes whether a card is face up or down. that is if it's face up it will be face down after and if it's face down it will be face up after. the method should not take any parameters and should not return a value , but will change the state pf the card
3 Bag.java Page not found Card.java X Person.java WarmUp.java 1 2 A class representing a standard four suit, thirteen numbered 3 * playing card 5 * Gauthor drk04747 Cheat She Create at applicatio Introduct 4 6 This cheats create the ti application a Java proje print "Hello run If you need! (?) to the rig Clic Open the Create a Create you Add a print Run your 8 public class Card { 9 // Card values in and max (inclusive) 10 private static final int MIN_NUMBER = 1; 11 private static final int MAX_NUMBER = 13: 12 13 // the number on the card and the suit 14 private int number; 15 private String suit; 16 17 18 * Create a new card 19 20 * Oparan tempNumber 21 * @param tempSuit 22 */ 23e public Cardint tempNumber, String tempSuit){ 24 if( isvalidNumber(tempNumber)) { 25 number = tempNumber; 26 lelse { 27 System.out.println("Invalid card number: " + tempNumber); 28 System.out.println("Defaulting to 1"); 29 number = 1; 38 } 31 32 if( isValidsuit(tenpSuit)) { 33 suit = tempSuit; 34 } else { 35 System.out.println("Invalid suit: " + tempSuit); 36 System.out.println("Defaulting to hearts"); 37 suit = "hearts": 38 > 39 } 40 41 42 Get the suit of this card 43 44 return the suit 45 */ 469 public String getSuit({ return suit: 48 > 49 50 51 Get the number associated with this card 52 53 return the number 54 55 public int getNumber04 56 return number: 57 } 58 von Lab algt git rial: I WarmUp.java "4 0 Page not found Card.java X Person.java * @return the suit */ public String getSuit() { return suit; } Bag.java 44 45 46e 47 48 49 50e 51 52 53 54 55e 56 57 58 598 60 61 62 63 64 65 66 67 68 * Get the number associated with this card * * @return the number */ public int getNumber({ return number; } * Cheat and change this card to an ace! */ public void cheat() { number - 1; // ACE! } /** 70 71 72 73 74 * Two cards are equal if their number and suit are the same */ public boolean equals(Card other){ return number == other.number 68 suit.equals(other. suit); // could also write as: 1/ number == other.getNumber() && suit.equals(other.getSuit(); 3 public String toString(){ return number + " of " + suit: } *** n1-lyveni * Check if the number is a valid number for the card * @param number * @return whether or not the number is valid private boolean isvaldNumber(int number) { return number >= MIN_NUMBER 66 number 81 82 83 84 85 86 87 88 89e 90 91 92 93 94 95 96 Check if the suit is a valid suit Oparan suit * @return whether or not the suit is valid / private boolean isValidSuit(String suit) return suit.equals("spades") !! suit.equals("hearts") TT suit.equals("clubs") II suit.equals("diamonds"); I 98 99 100 101

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

Seven NoSQL Databases In A Week Get Up And Running With The Fundamentals And Functionalities Of Seven Of The Most Popular NoSQL Databases

Authors: Aaron Ploetz ,Devram Kandhare ,Sudarshan Kadambi ,Xun Wu

1st Edition

1787288862, 978-1787288867

More Books

Students also viewed these Databases questions

Question

What are the objectives of Human resource planning ?

Answered: 1 week ago

Question

Explain the process of Human Resource Planning.

Answered: 1 week ago