Draw a uml diagram of each of the shapes

Assignment Help JAVA Programming
Reference no: EM13665343

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, in your own words, 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 the line of code:

output = new BufferedWriter(new FileWriter(file)) ; in the ExportToFile method in ShapesList.java .

5. Briefly explain the code in mySort() in the ShapesList class. What attribute are the shapes being sorted by?

6. 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?

7. Briefly name and describe one other sorting algorithm that could have been used.

8. 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?

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

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

Your first coding task is to implement and test a class that represents a Person. A Person object has a firstName, lastName, address, phoneNumber, yearOfBirth, height, weight and sex.

To complete this task, you are required to:

1. Create a new package in Eclipse named assignTwoStudentNNNNNN where NNNNNN 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 Person in a file called Person.java. Starter code has been provided with this assignment, copy this starter code into your Person.java file. Complete the constructors that will create a Person object.

3. Author all mutator and accessor (set and get) methods and the toString() as indicated in the UML diagram.

4. Ensure that your Person class includes the following validation within the mutator (set) methods:

a. The lastName of the Person cannot be null or an empty String (ie ""). If an attempt is made to set the lastName to an invalid value the method should set the name to "Invalid Name" unless there is already a lastName, in which case it shouldn't change. In either case the method should return false when attempting to set an invalid value.

b. The yearOfBirth of the Person must be greater than or equal to 1900. If an attempt is made to set the value of the yearOfBirth to an invalid value the method should return false and not change the value of the yearOfBirth.

Part C - Development of extended Classes using inheritance

Your second coding task is to implement and test a class that represents a Player. For this assignment a Player is a Person with additional attributes such as position, playerNumber, registrationNumber and feesOwed. A Player isA Person. The Player class will extend a Person class, so the firstName, lastName, address, phoneNumber, yearOfBirth, height, weight and sex will be inherited from the Person class. After you have created the Player class, you are asked to create a similar class for another type of Person that you choose (e.g. Team Manager, Coach, Scorer....).

To complete this task you are required to:

1. Use the UML diagram provided to implement the class Player in a file called Player.java. Ensure that you adhere to the naming used below as this class will be used by other classes that you will develop. Starter code is provided for you to copy.

2. Make sure that your Player class extends the Person class.

3. Ensure that your class includes the following validation within the mutator (set) methods:

a. playerNumber must be between 4 and 50. If an attempt is made to set the playerNumber to an invalid amount, then the method should set the playerNumber to three and return false, otherwise set theplayerNumber as given and return true.

b. feesOwed cannot be a negative number. If an attempt is made to set the value of the feesOwed to an invalid value the method should return false without changing the value.

4. Write additional methods for toString() and a method to check equality with another Player (equality should be based on playerNumber being the same for both Players).

5. Select two Players that you will create. Choose values for each of the data attributes for each Player. Write a class called TestTeamListClass (starter code is provided to copy from) and within the main method write code that will :

a. Instantiate an instance of the Player class for one of the Players you selected using the Player() constructor;

b. Set all of the instance variables to the appropriate values using the mutator methods (set);

c. Change the yearOfBirth to increase the yearOfBirth of the first Player by 2 years.

d. Instantiates an instance of the class Player for a second different Player contained in the table below using the Player(firstName:String, lastName:String, address:String, phoneNumber:String, yearOfBirth:int, height:double, weight:double, postion:String, playerNumber:int, registrationNumber:String, feesOwed:double) constructor

e. Display both of the Players that you have created using the toString() method

f. Display both of the Players that you have created using individual accessor (get) methods in a print statement

Part D - Development of the TeamList class

Using the UML diagrams provided and the information below you are required to implement and test classes that represent a TeamList object. For this assignment a TeamList contains multiple Persons up to a specified capacity. (This may be modeled on the ShapesList class in the sample code. The ShapesList class contains multiple Shapes in an array. Your TeamList will in a similar way contain multiple Persons in an array.)

1. You have been provided with a starting point in TeamList.java. Write get and set methods as well as an addPerson method.

2. Create a method for sorting the Persons in the TeamList (model this on the ShapesList mySort() method)

3. Update the class TestTeamListClass adding in code to:

a. Create an instance of the TeamList class
b. Add at least two Players created to the TeamList class using the addPerson() method
c. Add at least one other Person (e.g. Coach or Scorer (the one you have already created)) to the TeamList class

d. Display the details of the teamlist that you have created using the toString() method in the TeamList class - these should be accessed via the instance of the TeamList class that you have created

e. Display all of the Persons in the teamlist by looping through and accessing each Person in turn. Each Person should be accessed via the instance of the TeamList class you have created, then printed using the toString() method on that Person.

Part E - Using the Classes - Implementation of Menu System

Include further test cases. Create a new class called TeamListSystem.java. This class is to be used to implement a basic menu system. You may find some of the code you have already written in the TestMemberListClass.java can be copied and used with some modification here. You may also find the menu code from assignment 1 helpful as an example of using a switch statement to process the menu options. Each menu item should be enacted by choosing the appropriate method on the TeamList object.

The menu should include the following options:

1. Populate the TeamList
2. Display Persons in TeamList
3. Sort Persons data
4. Import data (ITECH5000 students only)
5. Export data (ITECH5000 students only
6. Exit

-Populate the TeamList - write a populate method that will insert data hardcoded in your method directly into each Person. You will use the set methods on your Player object and the set methods on your additional Person (Hint: copy this code from your TestMemberListClass.)

-Display Data - display the data of all Persons in the teamlist, using your toString() method on the TeamList object.

-Sort data should utilise some form of sorting algorithm to sort the Persons into ascending order of age. (Hint: look at the sort method in the ShapesList class. It sorts on area of the shape, you need to sort based on yearOfBirth of the Person.)

For students enrolled in ITECH5000 ONLY:

-Import data - this menu should read in data from the file called SampleData.txt. You are required to add the additional data described above to this file.

- Export data - save the data to a new file ExportData.txt

Reference no: EM13665343

Construct a bulls and cows program for my intro java class

construct a Bulls and Cows program for my intro Java class. This program needs to perform the basic functions of the game (determining how many cows there are and how many bul

Use random function to create account number

Add a static method numAccounts that returns the total number of accounts. (Think about why this method should be static -- its information is not related to any particular

Program that allows two players to play tic-tac-toe

Implement a program that allows two players to play tic-tac-toe. Draw the game grid and an indication of whose turn it is (X or O). Upon the next click, check that the mouse

Develop a data type for the time of day

Time. Develop a data type for the time of day. Provide client methods that return the current hour, minute, and second, as well as to String() and compare To() methods. Deve

Write a class named test scores

Write a class named TestScores.The class constructor should accept an array of test scores as an argument.The class should have a method that returns the average of the test s

Reimplement the labeledpoint class of exercise

Reimplement the LabeledPoint class of Exercise P9.12 by storing the location in a java.awt.Point object. Your toString method should invoke the toString method of the Point

Discusses the software development life cycle

A bug can be defined as an unexpected defect in a computer program Number of faults, flaws and imperfection can be encountered in an application developed with a given techn

Find the appropriate bucket

Modify Entry to include the extra field for the next reference. The method findIndex will need to utilize a hash value to find the appropriate bucket. Methods bucketGet and

Reviews

Write a Review

 
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