Part I: General Project Information

All projects are individual projects unless it is notified otherwise. No late projects will be accepted.

A project will receive no credit if one the following is true.

The project is late.
The project is a copy and modification of another student’s project. (Both will receive 0.)
The project is copied from the Internet or other resources.

Students must turn in their original work. Any copied work from others and/or Internet such as chegg.com will not be credited. Any cheating violation will be reported to the college. Students can help others by sharing ideas, but not by allowing others to copy their work. 

All projects must be submitted via Blackboard. No late projects will be accepted.

Documents to be submitted as a zipped file:
UML class diagram(s) – created with Violet UML, ArgoUML, or StarUML
Java source file(s) with Javadoc inline comments – (Java classes created with eclipse.)
Supporting files if any (For example, files containing all testing data.)
Students are required to submit a design, all error-free source files that compile with Javadoc inline comments, and supporting files. Lack of any of the required items will result in a really low credit or no credit.

Part II: Project grading rubric

Components
Max points
UML Design (See an example in part II.)
Max. 10 points
Javadoc Inline comments (See an example in part II.)
Max. 10 points
The rest of the project
Max. 40 points
All projects will be evaluated based upon the following software development activities.
Analysis:
Does the software meet the exact specification / customer requirements?
Does the software solve the exact problem?
Design:
Is the design efficient?
Code:
Are there errors?
Are code conventions followed?
Does the software use the minimum computer resource (computer memory and processing time)?
Is the software reusable?
Are comments completely written in Javadoc format?
a. Class comments must be included in Javadoc format before a class header.
b. Method comments must be included in Javadoc format before a method header.
c. More inline comments must be included in either single line format or block format inside each method body.
d. All comments must be completed in correct format such as tags, indentation etc.
Debug/Testing:
Are there bugs in the software?
Documentation:
Complete all documentations that are required.

Part III: Examples on how to meet project requirements

To complete a project, the following steps of a software development cycle should be followed. These steps are not pure linear but overlapped.
Analysis-design-code-test/debug-documentation.
1) Read project description to understand all specifications(Analysis).
2) Create a design (an algorithm for method or a UML class diagram for a class) (Design)
3) Create Java programs that are translations of the design. (Code/Implementation)
4) Test and debug, and (test/debug)
5) Complete all required documentation. (Documentation)

The following shows a sample design.


The corresponding source codes with inline Javadoc comments are included on next page.


Part IV: Project description

Note to students who are majored in ECE: The graphical user interface source codes are provided in Java. If you choose to write in C/C++, you may use a console as the user interface. However, creating a GUI using C/C++ is a great exercise although it is not required.

Project 3 The 24-point card game

The 24-point card game is to pick any 4 cards from 52 cards, as shown in the figure below. Note that the Jokers are excluded. Each card represents a number. An Ace, King, Queen, and Jack represent 1, 13, 12, and 11, respectively. You can click the Refresh button to get four new cards.

Specification:

Enter an expression that uses the four numbers from the four selected cards. Each number must be used once and only once. You can use the operators (addition, subtraction, multiplication, and division) and parentheses in the expression. The expression must evaluate to 24. After entering the expression, click Verify button to check whether the numbers in the expression is correct. Display the verification in a message window (see figures below).

Assume that images are stored in files named 1.png, 2.png, … , 52.png, in the order of spades, hearts, diamonds, and clubs. So, the first 13 images are for spades 1, 2, 3… 13.

Assume that no spaces are entered before the first token, in between tokens, and after the last tokens.

Assume that only numbers can be entered as operands. 

Numbers match and the result is 24.

Numbers don’t match.

Numbers don’t match.

More example,
If 2,3,4,5 are selected and displayed, user can try one of the following expressions to win.
2*((3+4)+5)
2*(3+(4+5))
2*((3+5)+4)
2*(3+(5+4))
2*((4+3)+5)

Design:
The following is the design diagram. Part of the design(Graphical User Interface, GUI) has been implemented. Please download the provided source codes, and complete the rest of the project.

A graphical user interface is designed and implemented using
Swing components/containers. Proper events are handled. Here is the containment hierarchy:

1) The frame contains a panel (JPanel).
2) The panel contains all components in proper layouts.

A card can be made using a label with an image icon.

 To store images, create folder image in the project folder, create a subfolder card, and store all images in folder card. Note: This is required so that we can run your project without errors.

3) A driver program creates a frame (JFrame) in main.

Other classes( To be completed):(No static methods)
Expression Class:

To evaluate an user-entered infix expression, the infix expression MUST be converted to postfix expression first, and then the postfix expression is evaluated if numbers are correct. Define Class Expression including the method infixToPostfix() and method evaluate(). Other methods such as constructors and helper methods should be included in class Expression. From the GUI side, Expression constructor is called with a string, user-entered expression, passed into the constructor, and the reference to this Expression object is used to call the evaluate method(See below.).
/**
* Evaluates current expression, and return a value to indicate if the result is
* equal to 24. Converts this infix expression into a postfix form, and evaluates
* the postfix form.
* @return A boolean value specifying if the result is equal to 24
*/
public boolean evaluate() {
Expression exp = new Expression(this.expression.getText().trim());
return exp.evaluate() == 24;
}

The algorithm (infix to postfix using a stack) is listed below.
As long as there are more tokens, get the next token.
If the token is an operand, append it to the postfix string.
If the token is "(", push it onto the stack.
If the token is an operator, (order operators by precedence)

if the stack is empty, push the operator onto the stack.

if the stack is not empty, pop operators of greater or equal precedence from the stack and append them to postfix string, stop when you encounter ")" or an operator of lower precedence or when the stack is empty. And then, push the new operator onto the stack.

When you encounter a ")", pop operators off the stack and append them to the end of the postfix string until you encounter matching "(".

When you reach the end of the infix string, append the remaining content of the stack to the postfix String.
2) evaluate: This method should convert this infix expression to postfix, evaluates the postfix expression, and returns the result.
public int evaluate(){…}

3) Supporting methods.
A Generic ADT Stack:
Both infixToPostfix algorithm and evaluate algorithm must use a stack to store objects/tokens. A generic ADT 

Stack must be designed(GenericStackInterface) and implemented using an array list. It should have the following operations:
rations:
Construct an empty stack (GenericStack(){…} ).
Return the number of objects of this stack( getSize() {… }).
Return a reference to the top element of this stack( peek() {…}).
Add an object to the top of this stack( push(E o) {}).
Remove from the top of this stack( pop() {…}).
Indicate if this stack is empty( isEmpty() {}).
public class GenericStack{
private java.util.ArrayList list;

}

Code/Test/Debug:
Test the entire program completely.