Development of a simple program involving multiple classes

Assignment Help JAVA Programming
Reference no: EM13162843

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: EM13162843

Questions Cloud

State gas is added with no change in volume : If 0.130 mol a third gas is added with no change in volume or temperature, what will the total pressure become?
What mass of oxygen is collected : A sample of oxygen gas is collected over water at 25 degrees C. and a total pressure of 654 torr. The volume of gas collected is 500 mL. What mass of oxygen is collected? The vapor pressure of water is 25 degrees C at 23.8 torr.
Visual entertainment media shaped american culture and value : In 300 words what ways have various forms of visual entertainment media shaped American culture and its values?
What is the final volume of the balloon : a balloon is filled to a volume of 7.00 times 10^2 mL at a temperature of 20.0 degrees celcius. the balloon is then cooled at constant pressure to a temperature of 1.00 times 10^2 K. what is the final volume of the balloon?
Development of a simple program involving multiple classes : Development of a Simple Program Involving Multiple Classes and development of a basic Class, development of the Country and World classes
What change in the number of moles of ag : what change in the number of moles of Ag occurs in the system? (2)what change in the concentration of Ag occurs in the system?
What is the partial pressure of oxygen in the mixture : A gaseous mixture of and contains 37.8 nitrogen by mass. What is the partial pressure of oxygen in the mixture if the total pressure is 785 ?
Positive contribution and negative consequence : Information technology influences the behavior of organizations. Name one effect of IT implementation and long-term usage you assume having a positive contribution and one having a negative consequence.
What is the new volume of the helium sample : the temperature of a 2.0 liter sample of heluim gas at STP is increased to 27 celsius and the pressure is decreased to 80.0 kPa. what is the new volume of the helium sample.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Application that generates a quiz

Create an application that generates a quiz. Prompt for the user's first and last name, college major, and confidence in test taking (high, medium, or low). The quiz should contain at least five true/false questions about horticulture. When the user ..

  Java application to declare and create a vector

Write a java application that perform the following task: declare and create a vector with initial size of 10, increment of 2

  Technical community blog

Write a blog article for a coding/technical community blog

  Classes and pointers experience using dynamic memory

To practice defining classes using separate compilation using classes, vectors, and pointers experience using dynamic memory.

  Java program to decide whether integer is perfect number

For example, 6 is a perfect number because 6 = 1 + 2 + 3. Write a Java program that decides whether integer is a perfect number.

  Solving programming problems

Write a computer program that will figure out the total of an order when given the amount of the order ($1000) and a sales tax rate of eight percent.

  Robot preparing for competition

Create an event so that the skateboard can be controlled by game player

  Write the logical expression in postfix notation.

Given symbols p, q, r, and s for propositions. Draw the binary tree representation of the logical expression ((p || r) && ! p ) || s) && (q || r). Write the logical expression in postfix notation.

  The game of pig

Write a program that allows a single player to practice the game (that is, there will be no opponent, just a single player). Play 5 turns in the game to get a total score for the player. Refer to the sample output below for a detailed example.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Elements from a html document

Function test Count List Elements should simply retrieve an array of all list elements on the page and assert that their total count is 3.

  Insert uml design diagrams, use case, classes

Insert UML design diagrams here (use case, class, and sequence diagram).

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