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

Questions Cloud

An electron moving by a velocity v in the positive : An electron moving by a velocity v in the positive x direction enters a region of uniform magnetic field that points in the positive z direction. The force on the electron will be in the positive y direction
What force does the fluid leave the needle : A 2.16 N force is applied to the plunger of a hypodermic needle. If the diameter of the plunger is 1.19 cm and that of the needle 0.199 mm, by what force does the fluid leave the needle?
A small electric immersion heater is utilized to heat : A small electric immersion heater is utilized to heat 110 g of water for a cup of instant coffee. The heater is labeled "200 watts", which means that it converts electrical energy to thermal energy at this rate. Compute the time needed to bring this ..
The financial and/or business aspects : The financial and/or business aspects.
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.
What is the focal length of the diverging lens : A converging lens with a focal length of 14.0 cm and a diverging lens are placed 26.0 cm apart, by the converging lens on the left. A2.00 cm high object is placed 22.0 cm to the left of the converging lens. The final image is 34.0 cm to the left of t..
Use the global edge website : Use the globalEDGE website
Decide the mirrors radius of curvature : A dentist utilizes a mirror to examine a tooth that is 1.25 cm in front of the mirror. The image of the tooth is formed 5.0 cm behind the mirror. Decide the mirror's radius of curvature.
Converging lens has a focal length : A converging lens has a focal length of 14.0 cm. Locate the images for object distances of (a) 14.0 cm, (b) 4,67 cm, and (c) 28.0 cm, if they exist. For each case, state whether the image is real or virtual, upright or inverted, and find the magnific..

Reviews

Write a Review

JAVA Programming Questions & Answers

  Instantiate two savingsaccount objects

saver1 and saver2, with balances of $2000.00 and $3000.00, respectively (was trying to figure out the formula, what I have written so far is as follows, and I am trying to see if I missed something

  Program (using java) that is suppose to find the largest

writing a program (using java) that is suppose to find the lowest integer that can be evenly divided by a range (ex. 1-25). I need help fixing/debugging it so it comes up with the proper output.

  Graphical application for computing statistics

Write a graphical application for computing statistics of a data set. Supply a text field and button for adding floating-point values, and display the current minimum, maximum, and average in a label.

  If there are 4 command line arguments

If there are 4 command line arguments (a b c filename.dat) then the engine should take a,b,c and store the resulting x1 and x2 in filename.dat working in silent mode (no use of screen)

  Write down several reasons why exception-handling

question 1 give several reasons why exception-handling techniques should not be used for conventional program

  Littlest rebel starring shirley temple

Compare the novel Little Women by Louisa May Alcott and the film The Littlest Rebel starring Shirley Temple. How do these two intertwine or influence each other?

  Create a histogram bar

Demonstrates an example of the user interface during your program's execution

  Savingsaccount and bankaccount objects

The only differences between SavingsAccount and BankAccount objects is that SavingsAccount have an interest rate and can compute interest when necessary. Add an instance variable and a method to SavingsAccount to allow for these items.

  Write a program to track hourly employee arrival

A company hires you to write a program to track hourly employee arrival and departure times from work. In essence, you are tasked to make an online time clock.

  What is a nested inner class

What is a nested inner class? What special privileges does a nested inner class have? Give an example of how you declare a nested inner class

  Write a java sorting application with two classes

Problem. Write a Java Sorting Application with two classes, JavaSort and JavaSortTest. Your JavaSort Class, as a minimum must contain sorting methods for BubbleSort, InsertionSort, ShellSort, MergeSort, and QuickSort.

  Sample papaer hello can you please help me to solve this

hello can you please help me to solve this sample paper and there is not submit date as this is for me but still i want

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