Question: Program Specifications This code is in java: In this assignment you will be writing an array-based implementation of the list ADT called ULArrayList and you

Program Specifications

This code is in java:

In this assignment you will be writing an array-based implementation of the list ADT called ULArrayList and you will use it to implement a hand of cards. The hand should be ordered based on the game being played (see below). A hand of cards will be represented by the Hand class. This class will store the cards in an ULArrayList . The cards will be ordered in the hand using a class that implements the Comparator interface for Cards.

The Java Comparator interface provides a type-independent way to specify that a class can compare two instances of another class. For more information on this interface see section 6.2.2 in the Core Java book or read the JavaDoc description of java.util.Comparator found here. You will write three separate classes that implement this interface, one for each of the following hand ordering:

Potential hand orderings:

Hearts

the cards should be sorted by suit and then rank

suits should be ordered as follows: clubs, diamonds, spades, hearts

within each suit the cards should be ordered by rank, from two to Ace

the only exception to these rules is the queen of spades, which should always be placed last in the hand

Spades

the cards should be sorted by suit and then rank

suits should be ordered as follows: hearts, clubs, diamonds, spades

within each suit the cards should be ordered by rank, from two to Ace

Go Fish

the cards should be sorted by rank and then suit

rank should be ordered: A->2->3 10->J->Q->K

within each rank the cards should be ordered: clubs, spades, hearts, diamonds

User Interface

Your program will take in exactly one argument from the command line (find more information about command line arguments in the Additional Notes section). If there is not exactly one argument your program should print an error message and exit. The argument will determine the hand ordering. It must be one of the following: --hearts", --spades", or --gofish".

After starting, your program should wait for user input. User input can take four forms, lines that start with +, lines that start with -, lines that contain only p, or lines that contain only q. Lines that start with + add cards to the Hand and should take the form: +. Lines that start with - remove cards from the Hand and should take the form -. Lines that contain only p ask the program to print the current Hand. Lines that contain only q should cause the program to quit. To simplify writing the ConsoleInterface class, ten should be represented by a T, e.g., TC for the ten of clubs. For example, given a run of the program with the --hearts option:

+QC

+QS

p

QC

QS

+3C

+2H

+TC

-3C

+2D

p

TC

QC

2D

2H

QS

q

Your program should not print anything other than the Hand, and it should only print that when prompted. If the user enters illegal input (e.g., -, +C9, +13C), your program should just ignore it. I will be using the diff program to compare the output of your program with my program. If you print extra stuff, it will be significantly more difficult to grade your program and you will lose points.

It is good design practice to separate the user interface of a program from the core logic of the program. As such, for this program you should define a ConsoleInterface class that handles reading in user input from the console, printing output, and updating the users Hand.

Additional Notes

Command line arguments in Java are stored in the args parameter of the main method.

Use the Run->Edit Configurations menu to set command line arguments in IntelliJ.

System.exit(...) is a method that exits the current program.

You may not use Collections.sort or Arrays.sort.

Required Classes and Methods

See the provided Javadoc for this project. The Javadoc for this project can be found on the Moodle page for this class. Note: Javadocs contain two descriptions for each class, method, and variable. A short, one-line description, and a longer, more in-depth, description. Be sure to read the longer one.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!