creating a uml diagram using java doc
creating a linkedstring construtor object/ chat array
jes/project2.pdt 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 a = 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. "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. 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); After Linkedstring a new Linkedstring ("AA");is executed, a new LinkedString object a is created with all characters stored in a linked list. mul1 -12 head After LinkedString b = new LinkedString ("BB"); is executed, another new LinkedString object b is created with all characters stored in a linked list. null
mu 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 ab 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. 2205-05-213-0502-XLIST_COURSE/Projects/project2.pdf 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. null mus mul > head head COPY copy copy > null null ma **** * head ab Modifying like this would violates object immutability. null - nuli * The R*****_ head head 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 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(1)). 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 substringfint! 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. ceinterface LinkedStringinterface LinkedString head Node Character count in Hem Object nert se previous Node 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 dass, 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 efficient to let main to do all. Method main should be very small and should be the only method in the class. 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 muninirlass linkedStringUtility is a helper class. Both classes are used for testing, 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 LastName FirstName Project 02 Analysis Report. o For example, Smith John Project 02 Analysis Report 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 and completely empty the bag (makeEmpty(). ADT Bag 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. Java has two types of exceptions: checked exceptions and runtime exceptions. Checked exceptions are instances of classes that are sub classes of java.lang.Exception class. They must be handled locally or explicitly thrown from the method. They are typically used when the method encounters a serious problem. In some cases, the error may be considered serious enough that the program should be terminated. Runtime exceptions occur when the error is not considered as serious. These types of exceptions can often be prevented by fail-safe programming. For example, it is fairly easy to avoid allowing an array index to go out of range, a situation that causes the runtime exception ArrayIndexOutOfBoundsException to be thrown. Runtime exceptions are instances of classes that are subclasses of the java.lang.RuntimeException class. RuntimeException is a subclass of java.lang. Exception that relaxes the requirement forcing the exception to be either handled or explicitly thrown by the method. In general, some operations of an ADT list can be provided with an index value. If the index value is out of range, an exception should be thrown. Therefore, a subclass of IndexOutOfBoundException needs to be defined. Also, an exception is needed when the list storing the items becomes full. A subclass of java.lang.RuntimeException should be defined for this erroneous situation. A full ADT bag should throw an exception when a new item is inserted. ADT Bag Implementation: Data structure arroy must be used to store all items in an ADT Bag list. The element type of the array should be Object type. Implement all classes included in the design, Javadoc comments need be written during this activity. 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 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(I)). 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. 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 LastName FirstName Project 02 Analysis Report. o For example, Smith John Project 02 Analysis Report 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 Part IV: Project description Project 1 Abstract Data Type(ADT) Bag The ADT Bag is a group of items, much like what you might have with a bag of groceries. In a software development cycle, specification, design, implementation, test/debug, and documentation are typical activities. The details are provided in the rest of the document. ADT Bag Specification: (Note: You should not change the names of the operations in your program. This should be included in an interface.) Specify operations to create an empty bag that can hold up to 50 items, put an item at the end of the list of the bag (insert(item)), remove the last item in the bag (removeLast). remove a random item from the bag (removeRandom(). (Note: a random item is an item at a random index.) get the index of the first occurrence of an item from the bag if it is existed (get(item)), get a reference to an item at position index( get(index)), check how many items are in the bag (size()). check to see if the bag is full (isFull()). check to see if the bag is empty isEmpty(). and completely empty the bag (makeEmpty()). ADT Bag 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 Java has two types of exceptions: checked exceptions and runtime exceptions Checked exceptions are instances of classes that are sub classes of jovo.lang. Exception class. They must be handled locally or explicitly thrown from the method. They are typically used when the method encounters a serious problem some cases, the error may be considered serious enough that the program should be terminated Part Ill: 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) jes/project2.pdt 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 a = 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. "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. 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); After Linkedstring a new Linkedstring ("AA");is executed, a new LinkedString object a is created with all characters stored in a linked list. mul1 -12 head After LinkedString b = new LinkedString ("BB"); is executed, another new LinkedString object b is created with all characters stored in a linked list. null mu 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 ab 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. 2205-05-213-0502-XLIST_COURSE/Projects/project2.pdf 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. null mus mul > head head COPY copy copy > null null ma **** * head ab Modifying like this would violates object immutability. null - nuli * The R*****_ head head 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 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(1)). 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 substringfint! 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. ceinterface LinkedStringinterface LinkedString head Node Character count in Hem Object nert se previous Node 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 dass, 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 efficient to let main to do all. Method main should be very small and should be the only method in the class. 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 muninirlass linkedStringUtility is a helper class. Both classes are used for testing, 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 LastName FirstName Project 02 Analysis Report. o For example, Smith John Project 02 Analysis Report 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 and completely empty the bag (makeEmpty(). ADT Bag 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. Java has two types of exceptions: checked exceptions and runtime exceptions. Checked exceptions are instances of classes that are sub classes of java.lang.Exception class. They must be handled locally or explicitly thrown from the method. They are typically used when the method encounters a serious problem. In some cases, the error may be considered serious enough that the program should be terminated. Runtime exceptions occur when the error is not considered as serious. These types of exceptions can often be prevented by fail-safe programming. For example, it is fairly easy to avoid allowing an array index to go out of range, a situation that causes the runtime exception ArrayIndexOutOfBoundsException to be thrown. Runtime exceptions are instances of classes that are subclasses of the java.lang.RuntimeException class. RuntimeException is a subclass of java.lang. Exception that relaxes the requirement forcing the exception to be either handled or explicitly thrown by the method. In general, some operations of an ADT list can be provided with an index value. If the index value is out of range, an exception should be thrown. Therefore, a subclass of IndexOutOfBoundException needs to be defined. Also, an exception is needed when the list storing the items becomes full. A subclass of java.lang.RuntimeException should be defined for this erroneous situation. A full ADT bag should throw an exception when a new item is inserted. ADT Bag Implementation: Data structure arroy must be used to store all items in an ADT Bag list. The element type of the array should be Object type. Implement all classes included in the design, Javadoc comments need be written during this activity. 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 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(I)). 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. 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 LastName FirstName Project 02 Analysis Report. o For example, Smith John Project 02 Analysis Report 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 Part IV: Project description Project 1 Abstract Data Type(ADT) Bag The ADT Bag is a group of items, much like what you might have with a bag of groceries. In a software development cycle, specification, design, implementation, test/debug, and documentation are typical activities. The details are provided in the rest of the document. ADT Bag Specification: (Note: You should not change the names of the operations in your program. This should be included in an interface.) Specify operations to create an empty bag that can hold up to 50 items, put an item at the end of the list of the bag (insert(item)), remove the last item in the bag (removeLast). remove a random item from the bag (removeRandom(). (Note: a random item is an item at a random index.) get the index of the first occurrence of an item from the bag if it is existed (get(item)), get a reference to an item at position index( get(index)), check how many items are in the bag (size()). check to see if the bag is full (isFull()). check to see if the bag is empty isEmpty(). and completely empty the bag (makeEmpty()). ADT Bag 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 Java has two types of exceptions: checked exceptions and runtime exceptions Checked exceptions are instances of classes that are sub classes of jovo.lang. Exception class. They must be handled locally or explicitly thrown from the method. They are typically used when the method encounters a serious problem some cases, the error may be considered serious enough that the program should be terminated Part Ill: 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)