Draw a uml diagram of each of the shapes

Assignment Help JAVA Programming
Reference no: EM13957762

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

Reference no: EM13957762

Questions Cloud

Calculate the distance over which the front end of the car : "A person who is properly constrained by an over-the-shoulder seat belt has a good chance of surviving a car collision if the decceleration does not exceed 26.0 G's (1.00 G = 9.8 m/s^2). Assuming uniform decceleration of this value, calculate the ..
About leadership characteristics and qualities : Complete a search of articles about leadership characteristics and qualities. Based on what you find and the readings for this module, write a 2-3 page paper about what you think is most important in motivating and leading followers.
Break roi down into profit margin and investment turnover : Comment on the change in financial performance between 2011 and 2012. Break ROI down into profit margin and investment turnover.
Analyze the literature on representative bureaucracy : Review and analyze the literature on Representative Bureaucracy. Present arguments for and against the importance and contributions of a representative bureaucracy
Draw a uml diagram of each of the shapes : 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.
Identifying risks and assessing probability of occurrence : Which one of the following is NOT one of the project manager’s role? Identifying risks and assessing their probability of occurrence. Determining the best fit of the project in the organizations vision.
What is the average spacing between vehicles : Collision-avoidance automated control systems, which operate by bouncing radar or sonar signals off surrounding vehicles and then accelerate or brake the car when necessary, could greatly reduce the required spacing between vehicles. If the averag..
Strengths and limitations of hormone replacement therapy : A description of the strengths and limitations of hormone replacement therapy. Based on these strengths and limitations, explain why you would or why you would not support hormone replacement therapy. Explain whether you would prescribe supplement..
What other communication method might result in less bias : Imagine you are doing a telephone survey of Latino families in California regarding health care needs and coverage for a government commission. You are encountering a very high non-response rate. What other communication method might result in less b..

Reviews

Write a Review

JAVA Programming Questions & Answers

  Create a java application that displays the product number

Create a product class that holds the item number, the name of the product, the numberof units in stock, and the price of each unit.

  Write down a java application which inputs three integers

write a java application that inputs three integers from the user and displays the sum average product smallest and

  Using your musicalinstrument class

Finally, create a Java test class that simulates using your MusicalInstrument class.  In your test class you should at a minimum: a) Construct 4 instances of your instrument, b) tune your instruments, c) print the name of your instrument d) print ..

  Approximate the volume of cheese in a rectangular hunk

You will create a program that will approximate the volume of cheese in a rectangular hunk of Swiss cheese. For this approximation you will assume that the holes in the Swiss cheese are of two types: spherical bubbles (all of the same size) or cyl..

  Create java application to create and maintain contact list

Create a JAVA application to create and maintain a contact list - Create a database to store the contact information.

  Create an application for disney''s cottages

Create an application for Disney's Cottages, a weekend getaway resort that rents cottages and boats to use on the local lake

  Create a graphical application stackdemogui

Create a graphical application StackDemoGUI that provides a button for push and pop from a stack, a text field to accept a string as input for push, and a text area to show the contents of the stack after each operation.

  Write a java statement to have the object from manage

Write a Java statement to have the object from manage its display area by dividing it into 3 rows which have 4 columns each.

  Have an array of integers with user input instead of given

change the current code to have an array of integers with user input intead of given input from the main where it says int[] a=....; And also from a text file but the same numbers as what is given in main.

  Design 3 shoppingbay is an online auction service that

3. shoppingbay is an online auction service that requires several reports. design a flowchart or psuedocode this is

  A java program that reads the records

A java program that reads the records from the golf.dat file and displays them. It also displays the name of the player with the best (lowest) golf score.

  Implement a threads and a gui interface

Implement a threads and a GUI interface using advanced Java Swing classes - Implement a JTable to also show the contents of the data file. There are lots of options here for extending your program.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd