数据结构代写 | CSI213 Data Structures Project2 | UML

COLLEGE OF ENGINEERING AND APPLIED SCIENCES DEPARTMENT OF COMPUTER SCIENCE CSI213 Data Structures
Project 02 Created by Qi Wang
Table of Contents
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 Part V: Project Analysis Report …………………………………………………………………………………………….. 10
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
• Analysis Report (See more information in project 02 description.)
• 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
• 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. 42 points
Project Analysis Report
• Advanced Writing
• Information Literacy
Max: 8 points
Advanced Writing: 4 points Information Literacy: 4 points
Scoring Rubric for Advanced Writing*
Organization
Level of Content
Development
Grammar and Mechanics
Style 4321 Format 4321
Scoring Rubric for Information Literacy**
Identify an information need 4 Formulate a research plan 4 Select and use tools 4 Gather information 4 Evaluate and synthesize information 4 Use information responsibly and ethically 4 Apply technology, software, and electronic tools to enhance learning 4
TOTAL SCORE _______ / 4
3 2 1 3 2 1 3 2 1 3 2 1 3 2 1 3 2 1 3 2 1
TOTAL SCORE _______ / 4
4 3 4 3 4 3 4 3
2 1 2 1 2 1 2 1
2

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.
3

The corresponding source codes with inline Javadoc comments are included on next page.
import java.util.Random;
/**
* Representing a dog with a name.
* @author Qi Wang
* @version 1.0
*/
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(“”);
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
Class comments must be written in Javadoc format before the class header. A description of the class, author information and version information are required.
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.
* 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
4

return false; }
//The specific object is a dog.
return this.name.equalsIgnoreCase(other.name); }
}
Dog other = (Dog)obj;
5

Part IV: Project description
Project 2 ADT Character String
Implement the ADT character string type, LinkedString , as another implementation of class String in Java. A doubly linked list must be used, as the data structure, to store a list of characters (there is ONLY one external reference, head, to the linked list). This class must be implemented as an immutable class as java class String.
In Java, String is an immutable object (its internal states, such as data structures, cannot be changed once it’s created). Immutable means that once the constructor for an object has completed execution that instance can’t be altered. This is useful as it means you can pass references to the object around, without worrying that someone else is going to change its contents. Any method that is invoked which seems to modify the value, will actually create another String. Your LinkedString class must be immutable as well. For example, three String objects, a, b, and ab, are created in the following code segment.
String a = new String(“AA”);
String b = new String(“BB”);
String ab = a.concat(b);
After String aa = new String(“AA”); is executed, a new String object a is created. “AA”
After String b = new String(“BB”); is executed, another new String object b is created. b
“BB”
After String ab = a.concat(b);is executed, another new String object ab is created. String a(this string) and String b( a string passed into method concat) are not changed due to String immutability. Method concat simply copies the contents of a and b, and use them to make a new string object.
ab
“AABB”
The LinkedString class uses a different data structure, a doubly linked list. This data structure is LinkedString ‘s internal state. An immutable LinkedString object means its linked list can’t be altered once the object is created. All characteristics and behaviors of LinkedString objects must be the same as Java String objects. When a LinkedString object calls a method, this LinkedString object and LinkedString object(s) passed into this method must be unchanged during invocation of this method. If the method returns a LinkedString object, a new LinkedString object must be made without changing this LinkedString object and other LinkedString existing objects. The following shows how object immutability can be enforced when implementing method concat.
For example, three LinkedString objects, a, b, and ab, are created in the following code segment. LinkedString a = new LinkedString (“AA”);
LinkedString b = new LinkedString (“BB”);
LinkedString ab = a.concat(b);
6

After LinkedString a = new LinkedString(“AA”);is executed, a new LinkedString object a is created with all characters stored in a linked list.
head
with all characters stored in a linked list.
head
After LinkedString ab = a.concat(b);is executed, another new LinkedString object ab is created with all characters stored in a linked list.
head
Method concat must be implemented in a way in which a new linked string is made without modifying this linked string a and the other linked string b to enforce object immutability. In order to do this, method concat can simply copy characters in order like this.
‘A’
null
‘A’
null
a
After LinkedString b = new LinkedString(“BB”);is executed, another new LinkedString object b is created
‘B’
null
‘B’
null
b
‘A’
null
‘A’
‘B’
‘B’
null
ab
‘B’
null
‘B’
null
‘A’
null
‘A’
null
head a
head b
copy
copy copy
Modifying like this would violates object immutability.
copy
‘A’
null
‘A’
‘B’
‘B’
null
head
ab
‘B’
‘A’
‘A’
null
null
‘B’
null
null
head a ab
head b
7

Carefully implement each method, and make sure object immutability is maintained.
ADT Character String (LinkedString)Specification: Specify operations to
Three overloading constructors:
• create an empty LinkedString instance.
A new character linked list is allocated so that it represents the sequence of 0 characters currently contained in the character list argument. (LinkedString()).
• create a LinkedString instance containing a sequence of characters.
A new character linked list is allocated so that it represents the sequence of characters currently contained in the character list argument. (LinkedString(char[])).
• create a LinkedString instance containing same sequence of characters as a String instance.
A new character linked list is initialized so that it represents the same sequence of characters as the String argument (LinkedString(String)).
Other methods (MUST be implemented to enforce object immutability):
• return the char value at the specified index. The first character in this linked character string is in position zero. (char charAt(int)). Note: This linked string must be kept immutable.
• concatenate the specified linked character string to the end of this linked character string (LinkedString concat(LinkedString)). Note: This linked string and the specified linked string must be kept immutable.
• returns true if, and only if, length() is 0. (boolean isEmpty()). Note: This linked string must be kept immutable.
• return the length of this linked character string (int length()). Note: This linked string must be kept immutable.
• return a new linked character string that is a substring of this linked character string (LinkedString substring(int, int)). Note: This linked string must be kept immutable.
ADT Character String Design:
Complete a UML diagram to include all classes that are needed to meet the specifications. An interface class is usually defined to include all operations. A class implementing this interface provides implementation details. Exceptions should to be considered when operations are designed.
In the design, you should include the design of the ADT Character String(LinkedString), the design of Node that is required for designing a doubly linked list. The following shows the skeleton of the design for this project.
8

ADT Character String Reference-based Implementation:
A doubly linked list must be used, as the data structure, to store a list of characters (there is ONLY one external reference, head, to the linked list). A doubly linked list must be designed and implemented first, and then it can be uses as the data structure of ADT Character String. The design of doubly linked list has been discussed in class, you must implement it, and use it as part of this project. Use Object as the element type of a node in a doubly linked list. Implement LinkedString so that it is consistent with the String class. A LinkedString object must be an immutable object.
Implement all classes included the design. Javadoc comments should be included during this activity. Class comments must be included right above the corresponding class header. Method comments must be included right above the corresponding method header. All comments must be written in Javadoc format.
ADT Character String Test/Debug:
Note: It is required to store all testing data in a file.
To test LinkedString design, all operations in the design must be tested. This can be done as follows:

• •



Create an array list of LinkesString objects using testing data stored in a text file, and check emptiness of all linked strings.
Display all linked strings and their lengths in the array list.
Retrieve the last character or mid character of each LinkedString object from the array list, and display them. Display all linked strings in the array list again to make sure that all objects are not changed.
Concatenate a linked string with next linked string, and display the concatenated string, repeat for the entire array list. Display all linked strings in the array list again to make sure that all objects are not changed.
Get sub strings and display both substrings and original strings.
Test other methods.
It is not
should invoke a method (start) that is decomposed into more methods (createList, displayList,…) in a separate class. Every method should be designed as a single-minded method. For example, Class LinkedStringTest contains method main; class LinkedStringUtility is a helper class. Both classes are used for testing.
public class LinkedStringTest{
efficient to let main to do all. Method main should be very small and should be the only method in the class. It
public static void main(String[] args){
LinkedStringUtility.start(); }
}
public class LinkedStringUtility {
/**
* Creates a list of LinkedString objects and operates on them. */
public static void start(){
ArrayList<LinkedString> list;; /**
* Create an array list of LinkesString objects using testing data * stored in a text file.
*/
/**
* Display all linked strings in the array list.
*/
Note: This class shows only two methods. You must design/implement the rest of the class.
list = createList(…);
9

displayList(list);
//The rest of the testing methods must be completed by yourself.
} }
Testing data file:
A linked string can be made with a string or an array of characters. To test the design of ADT Character String, you may store a list of names like this in a file. Read some of them as strings, and create linked strings with them. Continue to read more strings, convert them into char arrays, and use char arrays to make more linked strings.
Olivia
Oliver
Amelia
Harry
Isla
Jack
Emily
George
Ava
Noah
Lily
Charlie
Mia
Jacob
Sophia
Alfie
Isabella
Freddie
Grace
Oscar
Part V: Project Analysis Report Requirements:
• The report must be submitted as a PDF format. The report must be named using the following name convention.
o LastNameFirstNameProject02AnalysisReport.
o Forexample,SmithJohnProject02AnalysisReport
• The report must be at least 4 pages long, and must use Time New Roman 12, and 1.5 lines line
spacing.
The project analysis report is a written document describing the activities and details that have taken place during the project implementation. Project analysis plays an important role in the design, execution, feasibility and evaluation of projects. In this report, you will document details for the following items:
• Software Design and Implementation o Specification
o Design
o Code
o Test/Debug
a. Test cases
• Lesson learned
• Future development
o Revisions
10