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

  Design a class named large integers

Design a class named largeIntegers such that an object of this class can store an integer of any number of digits.

  Part - 1build a graphical user interface for displaying the

part - 1build a graphical user interface for displaying the image groups cluster in jmjrst. design and implement using

  Cross the dark knight and the living flame of love

What challenges does spain get from the text john of the cross the dark knight and the living flame of love?

  Adt for a two color double stack adt consists of two stacks

design an adt for a two color double stack adt that consists of two stacks one red and one blue and has its operations color coded versions of the regular stack adt operations.

  Java class to accept a user-s hourly rate of pay

Write a class that accepts a user's hourly rate of pay and the number of hours worked. Display the user's gross pay, the withholding tax (15% of gross pay), and the net pay (gross pay - withholding).

  Dijikstra for undirected graph using simple scheme with

dijikstra for undirected graph using simple scheme with array and fibonacci heap and compare the performanceresults

  Java applet to find how much federal tax we need to pay

Write a java applet to determine how much federal tax we need to pay assuming the tax rate is 12%.  Ask the taxable income.

  Allow the user to display a work history report

The 'report screen' shall:Allow the user to display a work history report for an individual or for all employees for the two weeks prior to the report request.

  standard graph with four quadrant

Write a program in java that asks the user for values of x and y, and displays the point as an ordered pair along with a message that describes where that point falls on the standard graph with four quadrant.

  In this project you need to write a program called gf2java

in this project you need to write a program called gf2.java to implement the finite field gfpnwhere p is a prime number

  Write an object-oriented java program to manipulate data

I want a simple java solution matching all the specifications in the document. The java program has to be made using Eclipseversion 4.2.1.

  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.

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