Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have this programming assignment for CSC 222 (Data Structures) using Java. I have all the classes done but Im having trouble putting it all

image text in transcribed

I have this programming assignment for CSC 222 (Data Structures) using Java. I have all the classes done but Im having trouble putting it all together into the main program. If someone could help me with it that would be great!

Stack Class:

import java.util.ArrayList; public class Stack { private ArrayList cards; public Stack() { cards = new ArrayList(); } public boolean push(Card c) { cards.add(0, c); return true; } public Card pop() { if (!cards.isEmpty()) { return cards.remove(0); } return null; } }

Queue Class:

import java.util.ArrayList; public class Queue { private ArrayList cards; public Queue() { cards = new ArrayList(); } public boolean enqueue(Card c) { cards.add(c); return true; } public Card dequeue() { if (!cards.isEmpty()) { return cards.remove(0); } return null; } }

Card Class:

public class Card { private String suit; private int value; public Card(String s, int v){ suit = s; value = v; } @Override public String toString(){ String[] sVal = {"Ace", "2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King"}; return sVal[value] + " of " + suit; } public int getVal(){ return value; } public String getSuit(){ return suit; } }

Deck Class:

public class Deck { private ArrayList deck; private Random rand; public Deck() { deck = new ArrayList(); rand = new Random(); initialize(); } public void init() { initialize(); } private void initialize() { String[] suit = {"Spades", "Diamonds", "Hearts", "Clubs"}; for (int i = 0; i

program2-2 [Compatibility Mode] References Mailings Review View 2 Caption Heading 1Heading 2 Data Structures CSC 222 Fall 2017 Programming Assignment #2-50 Points 3 So, we're going to be creating a card game. Are you excited yet? You ' be programming a modified version of poker! The rules are simple: the human player places a bet, and then each player (human and computer) is dealt 5 cards and the one with the higher total wins- simple, huh? If the human wins, the computer pays double (L.e. you get twice your bet back) and if the computer wins, the bet is lost The game starts by shuffing 2 decks of cards and putting them into a hopper. Then, the following steps occur until the player wants to quit or runs out of money: 1- player places a bet (less than or equal to his/her wallet), 2-each player is dealt 5 cards, and 3-the winner is determined. If there is a tie, the player keeps the bet. When the hopper is empty, the game is over Details: Comments The banner for your program (comment at the top) should include Name, Class Semester, Program number, and program description. The remainder should follow the WJU Computer Science standard. Execution. Your program will first display your welcome message, which should include your name and a brief description of the program (with anyappropriate instructions). Next, it will shutfle and then push 2 decks (array-based decks are fine) of cards into the hopper, which is a stack. Then the user places a bet. Next 5 cards are popped to the users "hand and 5 cards are popped into the computer's 'hand (both of the "hands" are queues). Then the totals are calculated (by dequeueing from each and and adding up the points) and the winner is determined. Last, the users wallet is updated. This continues unti the user runs out of money or wants to quit or the hopper is emptied note that you shouldn't attempt to start a game if there are not enough cards in the hopperl). Implementation You must use an ArrayList-based stack and an ArrayList-based queue. And I would expect to see at least five classes: Main, Stack, Queue, Deck, and Card. Heip Documentation: Include a statement of any outside help received in your main comment block Submittat: Use the Assignment feature of BlackBoard to submit your program. As always, extra effort will eam extra credit, but be SURE you get the basics down first

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

Harness The Power Of Big Data The IBM Big Data Platform

Authors: Paul Zikopoulos, David Corrigan James Giles Thomas Deutsch Krishnan Parasuraman Dirk DeRoos Paul Zikopoulos

1st Edition

ISBN: 0071808183, 9780071808187

Students also viewed these Databases questions