Create a monsterattack using method parameters

Assignment Help Computer Engineering
Reference no: EM132192994

Write an application in java that tracks information about monster attacks.

Important: use JOptionPane I/O, not Scanners and System.out, for this lab.

For this lab you will create a MonsterAttack class that represents one monster attack, an AttackMonitor class that aggregates data about attacks, and an MonsterAttackDriver class that instantiates an AttackMonitor.

One of the key functions of AttackMonitor is to read and write data using a text file, but you will complete this part in a future lab. Note that nearly all the methods in AttackMonitor and MonsterAttack will be instance, not static, methods.

Part I - MonsterAttack class

Each object of this class represents information about a single attack. The data on each attack includes an integer attack id, three ints representing the day of the month, the month, and the year of the attack, the name of the monster involved (assume that each attack involves only one monster), the location of the attack (String), and the name of the person reporting the attack (String).

MonsterAttack needs a constructor that sets all the instance fields listed above using its parameters. It should take the three components of the date as a single String in the format MM/DD/YYYY (eg, 01/31/2010). Use String's split method to split this String on the slashes, parse the resulting Strings to ints, and use them to set the values of the month, day, and year.

Monster attack also needs getters and setters for all the data fields and a toString() that uses the instance data to create and return a String similar to this: "Attack # 125: Godzilla attacked Tokyo on 6/25/2009. Reported by Kyohei Yamane."

Part II - AttackMonitor

Create an AttackMonitor class that keeps track of the MonsterAttack objects. It should contain an array list (not an array) of MonsterAttacks and an instance method called monitor() with a menu that allows the user to choose to quit or to do any of the tasks listed below, which must all be implemented in separate methods.

After doing any of these tasks, the program should return to the menu, so that the user can continue working on any series of tasks until he/she chooses to quit. Write instance, not static, methods to do each of the following:

Input information on a MonsterAttack. You will have to parse some of the input Strings to ints. When you have all the data, call the MonsterAttack constructor, using the input data, and add the new attack to the list of attacks.

Create a MonsterAttack using method parameters and add it to the list. In other words, this method will take parameters for the data fields, rather than taking them as user input.

Show the current list of attacks by iterating through the list, calling the toString() of each attack, and outputting the result to a dialog box.

Write this method so that the program does not crash if the list is empty.

Choose an attack from the array list and delete it. The easiest way to do this is to call the method that shows the information, then ask the user for the id number of the attack to delete. Use linear search to find the attack with that id and delete it. The id number may not be the same as the index in the list. Make sure the application does not crash if the user enters an id that does not appear in the list.

Part III: MonsterAttackDriver

The driver class should instantiate an AttackMonitor and call its monitor() method.

In order to make the application easier to test, the driver should provide hard coded data on three attacks. Use the data to create the three attacks and add them to the list in the monitor.

Reference no: EM132192994

Questions Cloud

Calculate and print the sum : Calculate and print the sum, product, difference and quotient. You should add the additional calculations for product, difference and quotient.
Write an applet that displays a car : Write an Applet that displays a Car. Use rectangles, ovals, polygons, lines and at least one string.
Display the incomes of mike and sara every year : Write an application in Java that displays the incomes of Mike and Sara every year until the income of Mike exceeds the income of Sara.
Write an application for lamberts vacation rentals : Assume that the locations are parkside for $600 per week, poolside for $750 per week, or lakeside for $825 per week.
Create a monsterattack using method parameters : Create an AttackMonitor class that keeps track of the MonsterAttack objects. Create a MonsterAttack using method parameters.
Wanted the margin of error : If the Pew researchers had wanted the margin of error (at the 95% confidence level) to be only 3% (0.03) instead of 4%, what sample size should they have used?
What is the efficiency class of this algorithm : Write an algorithm in pseudocode to perform the multiplication of a n cross n matrix A with a n cross 1 vector b.
Display the students name and the average of the grades : Write the Algorithm (not the program) for the following problem. A program needs get the following data from the user:
How large a sample would we have needed : If we wanted to estimate µ with 99% confidence interval with a margin of error of 2000, how large a sample would we have needed?

Reviews

Write a Review

 

Computer Engineering Questions & Answers

  Define a variable called boat-times-file that is direct file

Define a variable called Boat_Times_File that is a direct file of Interval values. Decide what form of data structure is appropriate for the given problem.

  What are the two main components of a uml diagram

What are the two main components of a UML Diagram? Show a scenario which illustrates each of the two main components for a given diagram.

  Explain the importance of understanding the various branches

Explain the importance of understanding the various branches of security covered in Chapter 1. Engineering Information Security.

  Determine the new optimum solution

For the diet model, suppose that the daily availability of corn is limited to 450 lb. Identify the new solution space, and determine the new optimum solution.

  Write a function that take as input a vector with quiz grade

Write a function that takes as input a vector with quiz grades and that determnes if the highest grade was obtained on the first quiz.

  What are the basic features and transfer speeds of dsl

What are the basic features and transfer speeds of DSL? What are the basic features and transfer speeds of cable modems?

  Implement the preemphasis filter across the entire waveform

MATLAB Implementation Use the M ATLAB functions filter ( ) and conv ( ) to implement the preemphasis filter for a = 0.98. What is the difference in the outputs.

  Explain how costs can be reduced with such a rating system

CPIS604 Project - R Coding and Modelling. Explain briefly how costs can be reduced with such a rating system. Suggest a refined question about saving costs, and what you expect to benefit from answering this question. What would be a way to answer th..

  Display all numbers in this computation using labels

If the second number is NOT a zero, do the operation, display all numbers in this computation using labels, and add them to the results.txt file.

  Would you consider the use of a compliance tool

You are the CISO of a large private financial company that is traded on the NY Stock Exchange. You were tasked by the the CIO to develop an IT compliance manage

  Create an erd crows foot diagram showing the entities

Create an ERD crows foot diagram showing the entities and the relationships between them with cardinalities.

  Describe one hard technical problem

Describe one hard technical problem you faced in your last major project. Add a section to your slide that describes the problem.

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