Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

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

Java, Programming

  • Category:- Java
  • Reference No.:- M9745695
  • Price:- $50

Priced at Now at $50, Verified Solution

Have any Question?


Related Questions in Java

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

Assignment taskwrite a java console application that allows

Assignment task Write a java console application that allows the user to read, validate, store, display, sort and search data such as flight departure city (String), flight number (integer), flight distance (integer), fl ...

Can someone help me please with those question1what is the

Can someone help me please with those question 1:what is the best data type for student id datatime,currency,number,decimal 2:which relationshipis preferable? one to one,one to many,many to many 3:if you add table A's pr ...

Solving 2nd degree equationsbull write the following java

Solving 2nd degree equations • Write the following Java methods • boolean real-sols(double a, double b, double c): it returns true if the 2nd degree equation ax2 + bx + c has real solutions • double solution1(double a, d ...

Assessment database and multithread programmingtasktask 1

Assessment: Database and Multithread Programming Task Task 1: Grade Processing University grading system maintains a database called "GradeProcessing" that contains number of tables to store, retrieve and manipulate stud ...

Fundamentals of operating systems and java

Fundamentals of Operating Systems and Java Programming Purpose of the assessment (with ULO Mapping) This assignment assesses the following Unit Learning Outcomes; students should be able to demonstrate their achievements ...

Object-oriented software development1 introduction 11

OBJECT-ORIENTED SOFTWARE DEVELOPMENT 1. Introduction 1.1 Assignment Requirement 1.2 Deliverables and Structure (what to submit) 1.3 Software Restrictions 1.4 How to score high... 1.5 Assumptions 2. System Requirements 2. ...

Retail price calculatorwrite a java program that asks the

Retail Price Calculator Write a JAVA program that asks the user to enter an item's wholesale cost and its markup percentage. It should then display the item's retail price. For example: (If an item's wholesale cost is 5. ...

Project descriptionwrite a java program to traverse a

Project Description: Write a java program to traverse a directory structure (DirWalker.java) of csv files that contain csv files with customer info. A simple sample in provided in with the sample code but you MUST will r ...

Assessment socket programmingtaskwrite a java gui program

Assessment: Socket Programming Task Write a JAVA GUI program that would facilitate text chatting/exchanging between two or multiple computers over the network/internet, using the concept of JAVA socket programming. If yo ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As