Question
Am stuck on this assignment, its on java if anyone can help?? Overview You may work on this assignment individually, or with one other person
Am stuck on this assignment, its on java if anyone can help??
Overview You may work on this assignment individually, or with one other person in CS 241. The goals of this assignment are to: 1. Become more familiar with interfaces and generics. 2. Foster a deeper understanding of arraylists. 3. Practice I/O and getting arguments from the command line. Program Specifications 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. File/Code Structure of Project Your project should be named using the following scheme: username.project (e.g., meehean_j.p1). All of the required classes for this project should be placed in the Java package cards. Any test files (JUnit or otherwise) should be placed in a separate Java package called test. All classes and methods detailed in the Javadoc for this project should be named exactly as they are in the Javadoc. Milestones The milestone for this program will count for a single week's work. Milestone 1 (due in lab on Feb 21): Your program must be able to take the command line arguments described above. If there is not exactly one argument your program should print an error message and exit. Your program should be able to add cards to a hand using the console interface. Your program should also be able to print the contents of a hand. For this milestone, your program does not need to sort the cards based on game type. The cards should be put in the hand in the order they were entered, last card last. Additionally, for this milestone your program does not need to use ULArrayList; you can use Javas ArrayList instead. How to hand in your program Create your project in a folder/directory named using the following naming scheme: username.project (e.g., meehean_j.p1). After you have created your project, this directory should include a src folder and .project file (at least). Once your project is complete, zip up the directory (right-click on it: Send to -> Compressed (zipped) folder). Then submit the zip file using Moodle. I strongly suggest that you test extracting your zip file in a different location to make sure that all of your .java files are inside of it. I cannot grade your assignment without your .java files and submitting the wrong files will not grant you an extension to the assignment. Be sure to put your name in @author tags in the comment section of each class. If you are working in pairs, be sure to put both of your names @author tags in the comment section of each class. Grading Your programs will be run and graded on correctness given a variety of input parameters. They will also be graded on the correct use of data structures, algorithms, and proper programming techniques. Relative Worth of Features In order to help you develop your programs, I have provided a breakdown of the relative worth (% of grade) for the features of this program. Implementing a working Cards program is worth up to 50% of the points for this project. You may implement ULArrayList using Javas ArrayList class instead of an array. The rest of your Cards program should use ULArrayList instead of ArrayList though. Implementing ULArrayList using an array is worth up to 50% of the points for this project. If you implement ULArrayList with an array and use it to build a working Cards program you can earn up to 100% of the points.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started