he CODE Must be in JAVA. Please show in simplest form and with comments. Please show the outputs as well (Minimum 2) public class Card{    int faceValue;    int suit;    Card(){       this.faceValue = 9;       this.suit = 1;    }    Card(int f,int s){       this.faceValue = f;       this.suit = s;    }    String getfaceValue(){       if(this.faceValue==1)          return "Ace";       else if(this.faceValue==2)          return "Two";       else if(this.faceValue==3)          return "Three";       else if(this.faceValue==4)          return "Four";       else if(this.faceValue==5)          return "Five";       else if(this.faceValue==6)          return "Six";       else if(this.faceValue==7)          return "Seven";       else if(this.faceValue==8)          return "Eight";       else if(this.faceValue==9)          return "Nine";       else if(this.faceValue==10)          return "Ten";       else if(this.faceValue==11)          return "Jack";       else if(this.faceValue==12)          return "Queen";       else if(this.faceValue==13)          return "King";       else          return "Inavlid";    }    String getSuit(){       if(this.suit==1)          return "Spades";       else if(this.suit==2)          return "Hearts";       else if(this.suit==3)          return "Clubs";       else if(this.suit==4)          return "Diamonds";       else             return "Invalid";    }    void setfaceValue(int s){       this.faceValue = s;    }    void setSuit(int s){       this.suit=s;    }    public String toString(){        return getfaceValue()+" of "+getSuit();     }  } //Test Driver for the Card public class TestDriver{    public static void main(String[] args) {       Card c1 = new Card(1,1);       System.out.println(c1);    } }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

The CODE Must be in JAVA. Please show in simplest form and with comments. Please show the outputs as well (Minimum 2)

public class Card{
   int faceValue;
   int suit;
   Card(){
      this.faceValue = 9;
      this.suit = 1;
   }
   Card(int f,int s){
      this.faceValue = f;
      this.suit = s;
   }
   String getfaceValue(){
      if(this.faceValue==1)
         return "Ace";
      else if(this.faceValue==2)
         return "Two";
      else if(this.faceValue==3)
         return "Three";
      else if(this.faceValue==4)
         return "Four";
      else if(this.faceValue==5)
         return "Five";
      else if(this.faceValue==6)
         return "Six";
      else if(this.faceValue==7)
         return "Seven";
      else if(this.faceValue==8)
         return "Eight";
      else if(this.faceValue==9)
         return "Nine";
      else if(this.faceValue==10)
         return "Ten";
      else if(this.faceValue==11)
         return "Jack";
      else if(this.faceValue==12)
         return "Queen";
      else if(this.faceValue==13)
         return "King";
      else
         return "Inavlid";
   }
   String getSuit(){
      if(this.suit==1)
         return "Spades";
      else if(this.suit==2)
         return "Hearts";
      else if(this.suit==3)
         return "Clubs";
      else if(this.suit==4)
         return "Diamonds";
      else   
         return "Invalid";
   }
   void setfaceValue(int s){
      this.faceValue = s;
   }
   void setSuit(int s){
      this.suit=s;
   }
   public String toString(){ 
      return getfaceValue()+" of "+getSuit(); 
   } 
}

//Test Driver for the Card


public class TestDriver{
   public static void main(String[] args) {
      Card c1 = new Card(1,1);
      System.out.println(c1);
   }
}

In Assignment 4, you created a Card class that represents a standard playing card. Use this to design and implement a class called
DeckofCards that stores 52 objects of the Card class using an array. Include methods to shuffle the deck, deal a card, return the number of
cards left in the deck, and a toString to show the contents of the deck. The shuffle methods should assume a full deck. Document your
design with a UML Class diagram. Create a separate driver class that first outputs the populated deck to prove it is complete, shuffles the
deck, and then deals each card from a shuffled deck, displaying each card as it is dealt along with the number of cards left in the deck.
Hint: The constructor for DeckOfCards should have nested for loops for the face values (1 to 13) within the suit values (1 to 4) calling the
two parameter constructor. The shuffle method does not have to simulate how a deck is physically shuffled; you can achieve the same
effect by repeatedly swapping pairs of cards chosen at random.
Testing: Include two complete runs to demonstrate the random effect of shuffling.
Transcribed Image Text:In Assignment 4, you created a Card class that represents a standard playing card. Use this to design and implement a class called DeckofCards that stores 52 objects of the Card class using an array. Include methods to shuffle the deck, deal a card, return the number of cards left in the deck, and a toString to show the contents of the deck. The shuffle methods should assume a full deck. Document your design with a UML Class diagram. Create a separate driver class that first outputs the populated deck to prove it is complete, shuffles the deck, and then deals each card from a shuffled deck, displaying each card as it is dealt along with the number of cards left in the deck. Hint: The constructor for DeckOfCards should have nested for loops for the face values (1 to 13) within the suit values (1 to 4) calling the two parameter constructor. The shuffle method does not have to simulate how a deck is physically shuffled; you can achieve the same effect by repeatedly swapping pairs of cards chosen at random. Testing: Include two complete runs to demonstrate the random effect of shuffling.
Expert Solution
steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Developing computer interface
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education