1. Homepage
  2. Programming
  3. Intro to Java Project 4: Casino Night

Intro to Java Project 4: Casino Night

Engage in a Conversation
Intro to JavaCasino NightJava

Intro to Java Project 4: Casino Night

Background

Now that we know how to make Objects, we can use them to make programs that would have been very complicated otherwise. In this assignment, you will create a class that represents a single playing card (the Card class), and another class that represents a deck of playing cards (the Deck class). Once you complete both of the classes, you can test your work by running a simple java Blackjack game that will be provided to you. CourseNana.COM

Exercise

● Your job is to create and submit two new files: Card.java and Deck.java. The classes will need to follow these requirements: ○ The Card class: ■ Private variables: Will have two private String variables: suit and value. Suits are either “hearts”, “diamonds”, “clubs”, “spades”. Values are “two”, “three”, “four”, “five”, “six”, “seven”, “eight”, “nine”, “ten”, “jack”, “queen”, “king”, “ace”. ■ Constructor: The constructor to the Card class will take in a suit String, ■ Public Methods: Your class must have the following methods with the others to edit at the same time. specified return types. ● public String getSuit() // returns the suit of the card (either “hearts”, “diamonds”, “spades”, or “clubs”) ● public String getValue() // returns the value of the card (“ace”, “two”, “three”, ... “jack”, “queen”, “king”) ● public String getColor() // returns the color of the card (“red” or “black”). Hearts and Diamonds are red, Spades & Clubs are black. ● public String toString() // returns a String representation of the Card. Should look something like “ace of clubs” or “six of hearts” ○ The Deck class: ■ Private variables: Will have one private variable called deck: an ArrayList of Card objects representing the deck of cards. ■ Constructor: The constructor to the Deck class takes no arguments. Inside the constructor, you should create 52 card objects representing the 52 cards in a deck, and add them to the private deck variable. Hint: use loops! ■ Public Methods: Your class must have the following methods with the specified return types. ● public void shuffle() // shuffle the deck using a Random object. It should not return anything. ● public Card deal() // remove a Card object from one end of the deck and return it. Don’t worry about checking if the deck is empty. CourseNana.COM

Testing

To test your code AND play a fun game of Blackjack, put the Hand.java and Blackjack.java files into the same folder as your Card.java and Deck.java files. Then, compile & run Blackjack.java to play the game. I suggest playing the game a few times to make sure everything works properly. After playing for a little bit, submit only Card.java and Deck.java to gradescope to make sure the autograder is happy as well. Here is some sample output from a successful game of blackjack (and yeah, I won):' CourseNana.COM

VERY IMPORTANT NOTE: Gradescope will compile and run Blackjack.java to test your code. I understand that you did not create Blackjack.java. When Compiling Blackjack.java, java also compiles Card.java, Deck.java, and Hand.java. If the program compiles and says there is an issue within Blackjack.java, it means there’s a problem with the code that call into your classes! Blackjack.java was compiled and tested before going onto Gradescope. CourseNana.COM

Get in Touch with Our Experts

WeChat (微信) WeChat (微信)
Whatsapp WhatsApp
Intro to Java代写,Casino Night代写,Java代写,Intro to Java代编,Casino Night代编,Java代编,Intro to Java代考,Casino Night代考,Java代考,Intro to Javahelp,Casino Nighthelp,Javahelp,Intro to Java作业代写,Casino Night作业代写,Java作业代写,Intro to Java编程代写,Casino Night编程代写,Java编程代写,Intro to Javaprogramming help,Casino Nightprogramming help,Javaprogramming help,Intro to Javaassignment help,Casino Nightassignment help,Javaassignment help,Intro to Javasolution,Casino Nightsolution,Javasolution,