I need that to be done what the requirement needs. I need cover sheet automatic table of content and screen shots of the testing
Purpose
To provide students with the opportunity to apply the knowledge acquired and skills developed during the 11 weeks of the Course. This assignment extends from the learning of the first six weeks in the areas of understanding of primitive data types and the concept of collections (in the form of arrays) as well as structured programming including sequence, selection and repetition to beginning to understand and implement object oriented concepts and basic file input and output as well as sorting algorithms.
Learning Objectives
In the process of this assessment task you will:
- Identify and use the correct syntax of a common programming language (Java);
- Describe program functionality based on analysis of a given program;
- Recall and use typical programming constructs to analyse, design and implement simple software solutions; and
- demonstrate debugging and testing skills whilst writing code.
Part A - Code Comprehension
A Sample program is provided that creates a list of shapes stored in an array. This program uses classes: Shapes, Square, Rectangle and ShapesList. The main method is in the class: TestingShapesListClass. Conduct a careful examination of this code. Make sure you understand this code as it will help you with your own programming for this assignment. Using the uncommented sample code for classes: Shapes, Square, Rectangle and ShapesList provided, answer the following questions:
1. Draw a UML diagram of each of the Shapes, Rectangle and Square classes using the code that has been provided. Complete this using the examples that have been provide in the lecture slides.
2. Draw a UML diagram of the ShapesList class using the code that has been provided. Complete this using the examples that have been provide in the lecture slides.
3. Add appropriate comments into the file: ShapesList.java to explain all the methods. At a mimimum, explain the purpose of each method. For the more complex methods reading input from a file, sorting the data and exporting data to the file, insert comments to explain the code.
4. Explain what the purpose of the call to hasNextLine() in readFromFile() in ShapesList.java.
5. Briefly explain the code in bubbleSort() in the ShapesList class. What attribute are the shapes being sorted by? Name the sort algorithm that is being used. Explain in words how it works, using an example. Why do we need to use two for loops?
6. Briefly name and describe one other sorting algorithm that could have been used.
7. Explain the use of the return value in the getArea() method in the Rectangle class. What is it returning? Where does the value come from?
8. Examine the lines to open the output file and write the outputString in the ShapesList class:
File file = new File("export.txt"); System.out.println(file.getAbsolutePath());
output = new BufferedWriter(new FileWriter(file)); output.write(outputString);
Where is the output file located? Find BufferedWriter in the Java API documentation and describe the use of this object.
9. In the TestingShapesListClass file, in testrun6, the exportToFile method is called with an argument of ShapesList.toString(). What is the purpose of the ‘\r\n' in the toString() method of the ShapesList class that is used to produce the output string?
10. Briefly explain why a try and catch clause has been included in the code to read from the file. Remove this from the code and remove the input file and take note of the error. Re-add the line and investigate what happens if the input file is not present.
Part B - Development of a basic Class: Character
Your first coding task is to implement and test a class that represents a Character in a game. A Character object has properties relating to each character: the date of birth is stored in 3 instance variables: day, month, year; the eye colour, number of legs, power level and health level of the character are also stored. You may reuse significant parts of code from assignment 1's GameCharacters.java.
To complete this task, you are required to:
1. Create a new package in eclipse named assignment2_Student_NNNNNNNN where NNNNNNNN is your student number. You will author a number of classes for this assignment and they will all be in this package.
2. Use the UML diagram provided to implement the class Character in a file called Character.java.
Character
~ day: int
~ month: int
~ year: int
~ eyeColour: int
~ power: int
~ healthiness: int
+ add PowerToCharacter(): void
+ Character()
+ createC ha racterCode(int): void
+ decodeCharacterCode(): int
+ displayCharacterDetails(): void
+ displayOneCharacter(): void
+ getLegs(): int
+ getP ower(): int
+ setDay(int): void
+ setEyeColour(int): void
+ setHealthiness(int): void
+ setLegs(int): void
+ setMonth(int): void
+ setPower(int): void
+ setYear(int): void
+ toString(): String
Figure 1: UML Diagram for the class Character (* Note a more detailed UML diagram is provided in appendix)
As you implement the Character.java code, consider that you are now writing object oriented code to act on ‘this' character. Ensure that you add appropriate data validation code into your set methods. For example, your setLegs method will check that the integer argument passed in is between MIN_LEGS and MAX_LEGS before changing the value of the instance variable legs.
3. Create a constructor for the Character object that will give each character a unique characterNumber (e.g. this.characterNumber = characterCount++;) and initialise all other attributes to zero value. In order for each character to have a unique character number value, characterCount should be declared as a static class variable initialised to zero.
4. Author all mutator and accessor (set and get) methods and the toString() as indicated in the UML diagram. Copy the other methods from the assignment 1 code and modify the code so that it is now referring to this character. For example, in assignment 1, you may have referred to a particular attribute by referencing a position in the array. In this current assignment, the attribute will be an instance variable on the Character object. For example, in assignment 1, you may have had code such as: tableOfCharacters[choice][POWER] whilst in the modified code for this assignment, you may use a list of character objects in an array so that you choose a particular character as :
Character chosenCharacter = listOfCharacters[choice] and you then refer to the power for the chosen character as: chosenCharacter.power
5. Ensure that your Character class includes the validation within the mutator (set) methods to check that each attribute is valid (i.e. between the MIN and MAX values stored as constants). You may copy the constants from assignment 1 code. The constants are shown in the more detailed UML diagram in Appendix A of this document.
Part C - Development of extended Classes using inheritance
Your next task is to think about the object oriented paradigm in programming and describe how you would implement a hierarchy of special characters. If for instance, you eventually wanted to have 2 types of special characters: Fighter characters and Healing characters, each with the basic character attributes plus additional attributes. The Fighter character might have an attribute that represents its ability to kill other characters whilst a Healing character might be able to administer first aid to improve the health of another character.
1. Considering this potential requirement, describe how you might implement 2 new character classes Fighter.java and Healer.java and how they would relate to the Character.java class.
2. Would you be able to insert such characters in your character array in the Game object?
In approximately 200 to 250 words discuss your answers to the above questions.
Part D - Development of related Classes
Your second coding task is to implement and test a class that represents a Game. In the Game class you will have a collection of Character objects.
To complete this task you are required to:
1. Use the UML diagram provided to implement the class Game in a file called Game.java. In this class you will put all the code that is related to the collection (array) of characters. Eventually, you will create a Game object
e.g. Game myGame = new Game(); and then you will be able to access all your characters in the array of Character objects: myGame.listOfCharacters
Game
- END_REPORT: String =" - End o... {readOnly}
- NCHARACTERS: int = 3 {readOnly}
- listOfCharacters: Character ([])
- listOfCharactersFilled: boolean = false
- studentlD: int = 0
+ Game()
+ createCharacters(Scanner): void
+ displayAllCharactersRaw(): void
+ displayAllCharactersForrnatted(): void
+ toString(): String
+ displayTotalLegsAndPower(): void
+ obtainCharacterAttribute(Scanner, String, Stringfl, int, int):
Figure 2: UML Diagram for the class Game
Part E - Development of the MenuSystem class
The menu system developed will provide the interface to the user but will only call methods on the myGame object to ‘enact' the game. Within the menu system, you will need to create an instance object, myGame to reference the game. Create the menu system by creating a new class called MenuSystem.java . The UML class diagram in appendix A provides details on the methods that are in this class. This class is to be used to implement a basic menu system. You may find some of the code from assignment 1 can be copied and used with some modification here. Menu items should call the appropriate method on the myGame object. The menu should include the same options as your assignment 1 system:
Menu
====
Choose options to create, display or enhance your characters Option 1: Create your characters
Option 2: Display entered information of all characters Option 3: Display formatted information of all characters Option 4: Display a particular character
Option 5: Display total legs and power for all characters Option 6: Empower your character
Option 99: Quit
Part F - Implementing a Sort algorithm
Your final coding task is to utilise some form of sorting algorithm to sort the characters in a game into ascending order based on their power. (Hint: look at the sort method in the ShapesList class. It sorts on the area of the shape.)
Add a new Option to your menu that implements a sort of the array of Characters: Option 7: Sort characters based on power.
This option should call the sort method which you should implement in the Game class.
Attachment:- Assignment.rar