Data Structure代写 | Java 数据结构 | CSI213 Data Structures

COLLEGE OF ENGINEERING AND APPLIED SCIENCES DEPARTMENT OF COMPUTER SCIENCE CSI213 Data Structures

Part I: General project information ……………………………………………………………………………………… 02 Part II: Project grading rubric……………………………………………………………………………………………….. 02 Part III: Examples on how to meet project requirements……………………………………………………… 03 Part IV: Project description ………………………………………………………………………………………………….. 06

1

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.

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

    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.

  • 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 Internet or other resources.

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

2

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.

3

import java.util.Random;
/**
 * Representing a dog with a name.
 * @author Qi Wang
 * @version 1.0
 */

Class comments must be written in Javadoc format before the class header. A description of the class, author information and version information are required.

public class Dog{

open {

/**
 * The name of this dog
 */
/**
 * Constructs a newly created Dog object that represents a dog with an empty name.

A description of the method, comments on

TAB TAB

public Dog(){

private String name;

*/

open {

TAB

this(“”);

Comments for fields are required.

Method comments must be written in Javadoc format before the method header. the first word must be a capitalized verb in the third person. Use punctuation marks properly.

TAB

}/**
* Constructs a newly created Dog object withifaanyamaer.e required.

 * @param name The name of this dog

*/

public Dog(String name){ } this.name = name;

A Javadoc comment for a formal parameter consists of three parts:
– parameter tag,
– a name of the formal parameter in the design ,

(The name must be consistent in the comments and the header.)
– and a phrase explaining what this parameter specifies.
A Javadoc comment for return type consists of two parts: – return tag,

– and a phrase explaining what this returned value specifies

 * this dog and the name of this dog.
 * @return A string representation of this dog
 */

return this.getClass().getSimpleName() + “: ” + this.name; }

/**
 * Indicates if this dog is "equal to" some other object. If the other object is a dog,
 * this dog is equal to the other dog if they have the same names. If the other object is
 * not a dog, this dog is not equal to the other object.
 * @param obj A reference to some other object
 * @return A boolean value specifying if this dog is equal to some other object
 */

More inline comments can be included in single line or block comments format in a method.

public String toString(){

public boolean equals(Object obj){
//The specific object isn’t a dog. if(!(obj instanceof Dog)){

parameters if any, and comments on the return type

/**
 * Returns the name of this dog.
 * @return The name of this dog
 */

public String getName(){ } return this.name;

/**
 * Changes the name of this dog.
 * @param name The name of this dog
 */

public void setName(String name){

this.name = name; }

/**
 * Returns a string representation of this dog. The returned string contains the type of

return false;

4

}

             //The specific object is a dog.

return this.name.equalsIgnoreCase(other.name); }

}

Dog other = (Dog)obj;

5

Part IV: Project description 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.

6

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.

This part needs to be designed and implemented.

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

  • The frame contains a panel (JPanel).
  • 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.

7

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

• Other classes( To be completed):(No static methods)
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 following methods. Other methods such as constructors and helper methods should be included in class Expression.

• infixToPostfix: Converts this infix expression to a postfix expression, returns a postfix expression as a list of tokens. The algorithm is discussed in class.

        public ArrayList<String> infixToPostfix(){...}

The algorithm (infix to postfix) 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.

  • evaluate: This method should convert this infix expression to postfix, evaluates the postfix expression,

    and returns the result.

             public int evaluate(){...}
    
  • Supporting methods.
    Both infixToPostfix algorithm and evaluate algorithm must use a stack to store objects/tokens. Define interface

    GenericStackInterface, and implement it using an array list. It should have the following operations:

    • 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<E>{

… private java.util.ArrayList<E> list; }

Code/Test/Debug:

Test the entire program completely.

8