Part a -code comprehensionusing the uncommented sample code

Assignment Help JAVA Programming
Reference no: EM13376079

Part A -Code Comprehension

Using the uncommented sample code has been provided in Moodleanswer the following questions:

1. Draw a UML diagram of the Shoe class 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 Store class using the code that has been provided.  Complete this using the examples that have been provide in the lecture slides.

3. Explain in what the purpose of the call to hasNext() in readFromFile. 

4. Briefly explain the code in sortInventory.  What is the inventory being sorted by?  What is the sort algorithm that is being used.  Explainin words how it works. Why do need to use two for loops?

5. Briefly explain what other sorting algorithms could have been used.

6. What method of searching for shoes has been used in the program?  What other algorithm could have been used.

7. Explain the use of the return value (result) of the compareTo method in the Shoe class. 

8. Briefly explain why the line to open the input file:

Scanner inputFile = new Scanner(new File("C:\\orders.txt"));

has two \\ in the filename specification.  Where is the file located? What happens if only one \ is used? Is there another option that would not require these?

9. Examine the code in the saveToFile method.  How could this be improved for readability of the output file?  What is the purpose of the '\r\n'?

10.   Briefly explain why a throws has included in the code to read from the file.  Remove this from the code and take note of the error.  Re-add the line and investigate what happens if the "orders.txt" 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 City.  For this assignment aCity has a name, population (in millions eg 1.5F is 1.5 million), an elevation above sea level and an indication of whether the city is a capital.

To complete this task you are required to:

1. Use the UML diagram to implement the class City in a file called City.java.  You are to ensure that you adhere to the naming used below as this class will be used by other classes that you will develop.

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

a. The name of the City cannot be null nor an empty String (ie "").If an attempt is made to set the name to an invalid value the method should return false.

b. The population of the City must be greater than or equal to 1.  If an attempt is made to set the value of the population to an invalid value the method should return false.

3. Select two cities contained in the sample data within the Appendix - ensure that these two cities are in the one country.  Write a class called TestClasses and within the main method write code that will :

a. Instantiate an instance of the Class city one of the cities you selected using the City() constructor

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

c. Increase the population of the city by 10%.

d. Instantiates an instance of the Class city for a different city contained in the table below using the City(initName: String, initPopulation: float, initElevation: int, initIsCapital: boolean)  constructor

e. Decrease the population of the city by 5%

f. Display both of the cities that you have created using the toString() method

g. Display both of the cities that you have created using accessor (get) methods

Part C - Development of the Country and World classes

Using the UML diagrams provided and the information below you are required to implement and test classes that represent Country and World objects.  For this assignment a Country contains multiple cities up to a specified capacity.  The World contains multiple countries up to a specified capacity.

1. You have been provided with starting point in Country.java .  You are to ensure that you adhere to the naming used below as this class will be used by the World class that you will also develop.

2. Ensure that your class includes the following validation within the mutator methods:

a. The name of the Country cannot be null nor an empty String (ie "").  If an attempt is made to set the name to an invalid value the method should return false.

b. The population of the city must be greater than or equal to 1.

c. The number of cities added to the Country class cannot be greater than the capacity.

d. As a City is added to the Country the instance variable numCities should be increased by 1.

e. As a City is deleted (removed) from the Country the instance variable numCities should be decreased by 1.

3. Update the class TestClasses  adding in code to:

a. Create an instance of the Country class using one of the countries contained in the table in the Appendix

b. Add the two Cities created to the Country class using the addCity(City) method

c. Display both of the cities that you have created using the toString() method - these should be accessed via the instance of the Country class that you have created

d. Display both of the cities that you have created using accessor methods - each city should be accessed via the instance of the Country class you have created

Part D - Using the Classes

Create a new class called WorldDriver.  This class is to be used to implement a basic menu system.  The menu should include the following options:

1. Populate the World

2. Display Data

3. Sort World data

4. Runqueries

5. Exit

  • Populate the World - use the data provided and at least 3 Countries from the table below and an addition 2 cities of your own selection
  • Display Data - display the data of all countries and their cities contained within the World.
  • Sort data should utilise some form of sorting algorithm to sort the Countries of the World into alphabetical order.
  • Run queries should:
  • Display the Details of the cities with a population of 1 million or more
  • Display the Names of the cities with more than one word in their name
  • Delete all Australian cities with an elevation below 100m"
  • Allow the user to search for a city and/or country

Download:- Java.rar

Reference no: EM13376079

Questions Cloud

1list all the strong aqueous acids what is the difference : 1.list all the strong aqueous acids. what is the difference between a strong acid and a weak acid? how do the
1 which of the following best illustrates the concept of : 1. which of the following best illustrates the concept of the fact that people respond to incentives? jordan is
Two thermometers a and b are wrapped in pieces of gauze the : two thermometers a and b are wrapped in pieces of gauze. the gauze around thermometer a is moistened with water and the
A key comment i would like to make is about prescriptive : a key comment i would like to make is about prescriptive frameworks that essentially follows my main concern with
Part a -code comprehensionusing the uncommented sample code : part a -code comprehensionusing the uncommented sample code has been provided in moodleanswer the following questions1.
Assess the reliability of data gathered via paid internet : assess the reliability of data gathered via paid internet users. describe and assess the evaluation method being used
Part a1 give the role amp significance of or in business : part a1. give the role amp significance of o.r. in business amp industry for scientific decisions.2. the primary
A logic circuit has two 2-bit unsigned binary numbers x10 : a logic circuit has two 2-bit unsigned binary numbers x10 and y10 as the inputs and it has two 1-bit outputs. one of
The economy consists of a single individual who represents : the economy consists of a single individual who represents a large number of homogenous individuals. this

Reviews

Write a Review

JAVA Programming Questions & Answers

  One search function

One search function will use a sentinel to mark the end of the array. The other search function will use an array length (maximum legal index into the array) to determine when to exit the search loop. Both functions must return true when the searc..

  Create the class airplane

Your missions is to create the class Airplane. Each Airplane object should store the following information (fields):

  Write down ijvm code to remove top two words from stack

Write down IJVM code which will remove these top two words, multiply and put their product back on stack. You are allowed to use existing IJVM instructions only.

  Define inventory program assignment from java class

This is part 6 of the inventory program assignment from Java class IT 215 from UOP and all the codes are written well and includes everything all the functionality from the previous parts and there's absolutely no errors.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  1 ra row your boatprepare a world with a boat a person

1. ra row your boatprepare a world with a boat a person sitting in the boat an island and a pier located 25 meters from

  Define get and set functions and two constructors

Create a class called Building. It will have one data member of type string (used for a postal address). Define get and set functions and two constructors.

  Write a java program to register students for a college

Project is for designing and developing a College Registration program. Write a Java program to register students for a college

  Add a draw() method to horse class.

Add a draw() method to your Horse class. You will also need to create a couple of Horses in your DrawPanel class, and call the draw() method for each Horse from the paintComponent() method. There is no need to modify the DrawPanelDriver class.

  Create an application that demonstrates the use of the class

Create an application that demonstrates the use of the classes. Save the files as Player.java, Child.java, Actor.java, Musician.java, and UsePlayer.java.

  Calculates the cost of a mortgage

Write a class called Mortgage that calculates the cost of a mortgage. Prompt the user to enter the principal amount, the term in years, and the interest rate per year.

  Construct java program named collegelist

Construct a set of classes for a college to use in many student service and personnel applications. Classes you require to design include following:

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