SlideShare a Scribd company logo
// MonsterAttack.java
public class MonsterAttack {
int id;
int day, month, year;
String nameOfMonster;
String location;
int numOfVictims;
public MonsterAttack(int id, String date, String nameOfMonster, String location, int
numOfVictims) {
String arr[] = date.split("/");
this.id = id;
this.day = Integer.parseInt(arr[1]);
this.month = Integer.parseInt(arr[0]);
this.year = Integer.parseInt(arr[2]);
this.nameOfMonster = nameOfMonster;
this.location = location;
this.numOfVictims = numOfVictims;
}
int getId() {
return id;
}
void setId(int id) {
this.id = id;
}
String getNameOfMonster() {
return nameOfMonster;
}
void setNameOfMonster(String nameOfMonster) {
this.nameOfMonster = nameOfMonster;
}
String getLocation() {
return location;
}
void setLocation(String location) {
this.location = location;
}
int getNumOfVictims() {
return numOfVictims;
}
void setNumOfVictims(int numOfVictims) {
this.numOfVictims = numOfVictims;
}
String getDate(){
return month + "/" + day + "/" + year;
}
void setDate(String date){
String arr[] = date.split("/");
this.day = Integer.parseInt(arr[1]);
this.month = Integer.parseInt(arr[0]);
this.year = Integer.parseInt(arr[2]);
}
public String toString(){
return "Attack # " + id + "occurred on " + getDate() + ". " + nameOfMonster +
"attacked " + location + ", resulting in " + numOfVictims + " tragic fatalities.";
}
}
// AttackMonitor.java
import java.util.ArrayList;
import javax.swing.JOptionPane;
public class AttackMonitor{
ArrayList attacks = new ArrayList();
void input(){
String nameOfMonster, location, date;
int id, numOfVictims;
nameOfMonster = JOptionPane.showInputDialog("Enter the name of the monster");
location = JOptionPane.showInputDialog("Enter the location of attack");
date = JOptionPane.showInputDialog("Enter the date of attack");
id = Integer.parseInt(JOptionPane.showInputDialog("Enter the id of attack"));
numOfVictims = Integer.parseInt(JOptionPane.showInputDialog("Enter the number of
victims"));
MonsterAttack temp = new MonsterAttack(id, date, nameOfMonster, location,
numOfVictims);
attacks.add(temp);
}
void display(){
for(int i = 0; i < attacks.size(); i++){
System.out.println(attacks.get(i));
}
}
void delete(){
display();
int id = Integer.parseInt(JOptionPane.showInputDialog("Enter the id of attack to delete"));
int i;
for(i = 0; i < attacks.size(); i++){
if(attacks.get(i).getId() == id){
break;
}
}
if(i != attacks.size()) attacks.remove(i);
}
void monitor(){
int choice = Integer.parseInt(JOptionPane.showInputDialog("Enter 1 for adding new
attack, 2 for displaying attacks, 3 for deleting an attack, any other number to exit"));
switch (choice) {
case 1:
input();
break;
case 2:
display();
break;
case 3:
delete();
break;
default:
return;
}
}
}
// MonsterAttackDriver.java
Give sample input/output ot input file
Solution
// MonsterAttack.java
public class MonsterAttack {
int id;
int day, month, year;
String nameOfMonster;
String location;
int numOfVictims;
public MonsterAttack(int id, String date, String nameOfMonster, String location, int
numOfVictims) {
String arr[] = date.split("/");
this.id = id;
this.day = Integer.parseInt(arr[1]);
this.month = Integer.parseInt(arr[0]);
this.year = Integer.parseInt(arr[2]);
this.nameOfMonster = nameOfMonster;
this.location = location;
this.numOfVictims = numOfVictims;
}
int getId() {
return id;
}
void setId(int id) {
this.id = id;
}
String getNameOfMonster() {
return nameOfMonster;
}
void setNameOfMonster(String nameOfMonster) {
this.nameOfMonster = nameOfMonster;
}
String getLocation() {
return location;
}
void setLocation(String location) {
this.location = location;
}
int getNumOfVictims() {
return numOfVictims;
}
void setNumOfVictims(int numOfVictims) {
this.numOfVictims = numOfVictims;
}
String getDate(){
return month + "/" + day + "/" + year;
}
void setDate(String date){
String arr[] = date.split("/");
this.day = Integer.parseInt(arr[1]);
this.month = Integer.parseInt(arr[0]);
this.year = Integer.parseInt(arr[2]);
}
public String toString(){
return "Attack # " + id + "occurred on " + getDate() + ". " + nameOfMonster +
"attacked " + location + ", resulting in " + numOfVictims + " tragic fatalities.";
}
}
// AttackMonitor.java
import java.util.ArrayList;
import javax.swing.JOptionPane;
public class AttackMonitor{
ArrayList attacks = new ArrayList();
void input(){
String nameOfMonster, location, date;
int id, numOfVictims;
nameOfMonster = JOptionPane.showInputDialog("Enter the name of the monster");
location = JOptionPane.showInputDialog("Enter the location of attack");
date = JOptionPane.showInputDialog("Enter the date of attack");
id = Integer.parseInt(JOptionPane.showInputDialog("Enter the id of attack"));
numOfVictims = Integer.parseInt(JOptionPane.showInputDialog("Enter the number of
victims"));
MonsterAttack temp = new MonsterAttack(id, date, nameOfMonster, location,
numOfVictims);
attacks.add(temp);
}
void display(){
for(int i = 0; i < attacks.size(); i++){
System.out.println(attacks.get(i));
}
}
void delete(){
display();
int id = Integer.parseInt(JOptionPane.showInputDialog("Enter the id of attack to delete"));
int i;
for(i = 0; i < attacks.size(); i++){
if(attacks.get(i).getId() == id){
break;
}
}
if(i != attacks.size()) attacks.remove(i);
}
void monitor(){
int choice = Integer.parseInt(JOptionPane.showInputDialog("Enter 1 for adding new
attack, 2 for displaying attacks, 3 for deleting an attack, any other number to exit"));
switch (choice) {
case 1:
input();
break;
case 2:
display();
break;
case 3:
delete();
break;
default:
return;
}
}
}
// MonsterAttackDriver.java
Give sample input/output ot input file

More Related Content

PDF
X has +2 charge It has low first and second ioniz.pdf
PDF
Valence Bond Theory According to valence band the.pdf
PDF
total volume =25+25=50 ml total millimoles of KI=.pdf
PDF
This type of deformation is irreversible. However.pdf
PDF
stereoisomers .pdf
PDF
Some elements receive their respective symbol bas.pdf
PDF
phosphonium ylide is produced when phosphonium ha.pdf
PDF
N1 V1 = N2 V2 50 x M1 = 1.50 x 2 x 17.7 M M1 = 1..pdf
X has +2 charge It has low first and second ioniz.pdf
Valence Bond Theory According to valence band the.pdf
total volume =25+25=50 ml total millimoles of KI=.pdf
This type of deformation is irreversible. However.pdf
stereoisomers .pdf
Some elements receive their respective symbol bas.pdf
phosphonium ylide is produced when phosphonium ha.pdf
N1 V1 = N2 V2 50 x M1 = 1.50 x 2 x 17.7 M M1 = 1..pdf

More from anugrahafancy (20)

PDF
In chemistry, an amphoteric species is a molecule.pdf
PDF
Chemistry is the science of matter, especially it.pdf
PDF
Before this confederates began their general advance, General Lee pl.pdf
PDF
An understanding of periodic trends is important .pdf
PDF
Acid contains hydrogen ions. Thus, iodate will re.pdf
PDF
There is a difference between to connect to a network and to communi.pdf
PDF
The picture is not uploaded properly it is corrupted. please upload .pdf
PDF
No clarity in question . Not visibleSolutionNo clarity in ques.pdf
PDF
Date Account title Debit credit jan 30 cash 45000 common sto.pdf
PDF
Initial Value=2.5Drift rate per annum=0.4Variance rate per annum.pdf
PDF
IntroductionDarwin argused that living organisms evolved from one .pdf
PDF
import java.awt.LinearGradientPaint; public class searchComparis.pdf
PDF
Distance VectorLink StateIt Sends the entire routing tableIt S.pdf
PDF
Evolution of gymnospersm or plants without fruit which have a naked .pdf
PDF
ANSimport javax.swing.;import java.awt.; import java.awt.ev.pdf
PDF
a. Total asset turnover = Return on assets Profit margin= 0.145 .pdf
PDF
d) All but Iv is the right answer.Solutiond) All but Iv is the.pdf
PDF
=2^10=1024Solution=2^10=1024.pdf
PDF
2. b) fed on molecules with a chemical structure to pesticides.The.pdf
PDF
1.Management information systemMany of the different types of Inf.pdf
In chemistry, an amphoteric species is a molecule.pdf
Chemistry is the science of matter, especially it.pdf
Before this confederates began their general advance, General Lee pl.pdf
An understanding of periodic trends is important .pdf
Acid contains hydrogen ions. Thus, iodate will re.pdf
There is a difference between to connect to a network and to communi.pdf
The picture is not uploaded properly it is corrupted. please upload .pdf
No clarity in question . Not visibleSolutionNo clarity in ques.pdf
Date Account title Debit credit jan 30 cash 45000 common sto.pdf
Initial Value=2.5Drift rate per annum=0.4Variance rate per annum.pdf
IntroductionDarwin argused that living organisms evolved from one .pdf
import java.awt.LinearGradientPaint; public class searchComparis.pdf
Distance VectorLink StateIt Sends the entire routing tableIt S.pdf
Evolution of gymnospersm or plants without fruit which have a naked .pdf
ANSimport javax.swing.;import java.awt.; import java.awt.ev.pdf
a. Total asset turnover = Return on assets Profit margin= 0.145 .pdf
d) All but Iv is the right answer.Solutiond) All but Iv is the.pdf
=2^10=1024Solution=2^10=1024.pdf
2. b) fed on molecules with a chemical structure to pesticides.The.pdf
1.Management information systemMany of the different types of Inf.pdf

Recently uploaded (20)

PDF
Trump Administration's workforce development strategy
PDF
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 1)
PDF
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
PDF
David L Page_DCI Research Study Journey_how Methodology can inform one's prac...
PPTX
Computer Architecture Input Output Memory.pptx
PDF
advance database management system book.pdf
PPTX
Onco Emergencies - Spinal cord compression Superior vena cava syndrome Febr...
PDF
HVAC Specification 2024 according to central public works department
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
DOC
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
PPTX
Introduction to Building Materials
PPTX
20th Century Theater, Methods, History.pptx
PDF
MBA _Common_ 2nd year Syllabus _2021-22_.pdf
PPTX
Introduction to pro and eukaryotes and differences.pptx
PDF
1_English_Language_Set_2.pdf probationary
PDF
Weekly quiz Compilation Jan -July 25.pdf
PDF
AI-driven educational solutions for real-life interventions in the Philippine...
PPTX
ELIAS-SEZIURE AND EPilepsy semmioan session.pptx
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
Trump Administration's workforce development strategy
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 1)
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
David L Page_DCI Research Study Journey_how Methodology can inform one's prac...
Computer Architecture Input Output Memory.pptx
advance database management system book.pdf
Onco Emergencies - Spinal cord compression Superior vena cava syndrome Febr...
HVAC Specification 2024 according to central public works department
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
Introduction to Building Materials
20th Century Theater, Methods, History.pptx
MBA _Common_ 2nd year Syllabus _2021-22_.pdf
Introduction to pro and eukaryotes and differences.pptx
1_English_Language_Set_2.pdf probationary
Weekly quiz Compilation Jan -July 25.pdf
AI-driven educational solutions for real-life interventions in the Philippine...
ELIAS-SEZIURE AND EPilepsy semmioan session.pptx
Chinmaya Tiranga quiz Grand Finale.pdf
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape

MonsterAttack.javapublic class MonsterAttack {    int id;  .pdf

  • 1. // MonsterAttack.java public class MonsterAttack { int id; int day, month, year; String nameOfMonster; String location; int numOfVictims; public MonsterAttack(int id, String date, String nameOfMonster, String location, int numOfVictims) { String arr[] = date.split("/"); this.id = id; this.day = Integer.parseInt(arr[1]); this.month = Integer.parseInt(arr[0]); this.year = Integer.parseInt(arr[2]); this.nameOfMonster = nameOfMonster; this.location = location; this.numOfVictims = numOfVictims; } int getId() { return id; } void setId(int id) { this.id = id; } String getNameOfMonster() { return nameOfMonster; } void setNameOfMonster(String nameOfMonster) { this.nameOfMonster = nameOfMonster; } String getLocation() { return location; } void setLocation(String location) { this.location = location;
  • 2. } int getNumOfVictims() { return numOfVictims; } void setNumOfVictims(int numOfVictims) { this.numOfVictims = numOfVictims; } String getDate(){ return month + "/" + day + "/" + year; } void setDate(String date){ String arr[] = date.split("/"); this.day = Integer.parseInt(arr[1]); this.month = Integer.parseInt(arr[0]); this.year = Integer.parseInt(arr[2]); } public String toString(){ return "Attack # " + id + "occurred on " + getDate() + ". " + nameOfMonster + "attacked " + location + ", resulting in " + numOfVictims + " tragic fatalities."; } } // AttackMonitor.java import java.util.ArrayList; import javax.swing.JOptionPane; public class AttackMonitor{ ArrayList attacks = new ArrayList(); void input(){ String nameOfMonster, location, date; int id, numOfVictims; nameOfMonster = JOptionPane.showInputDialog("Enter the name of the monster"); location = JOptionPane.showInputDialog("Enter the location of attack"); date = JOptionPane.showInputDialog("Enter the date of attack"); id = Integer.parseInt(JOptionPane.showInputDialog("Enter the id of attack")); numOfVictims = Integer.parseInt(JOptionPane.showInputDialog("Enter the number of victims"));
  • 3. MonsterAttack temp = new MonsterAttack(id, date, nameOfMonster, location, numOfVictims); attacks.add(temp); } void display(){ for(int i = 0; i < attacks.size(); i++){ System.out.println(attacks.get(i)); } } void delete(){ display(); int id = Integer.parseInt(JOptionPane.showInputDialog("Enter the id of attack to delete")); int i; for(i = 0; i < attacks.size(); i++){ if(attacks.get(i).getId() == id){ break; } } if(i != attacks.size()) attacks.remove(i); } void monitor(){ int choice = Integer.parseInt(JOptionPane.showInputDialog("Enter 1 for adding new attack, 2 for displaying attacks, 3 for deleting an attack, any other number to exit")); switch (choice) { case 1: input(); break; case 2: display(); break; case 3: delete(); break; default: return; }
  • 4. } } // MonsterAttackDriver.java Give sample input/output ot input file Solution // MonsterAttack.java public class MonsterAttack { int id; int day, month, year; String nameOfMonster; String location; int numOfVictims; public MonsterAttack(int id, String date, String nameOfMonster, String location, int numOfVictims) { String arr[] = date.split("/"); this.id = id; this.day = Integer.parseInt(arr[1]); this.month = Integer.parseInt(arr[0]); this.year = Integer.parseInt(arr[2]); this.nameOfMonster = nameOfMonster; this.location = location; this.numOfVictims = numOfVictims; } int getId() { return id; } void setId(int id) { this.id = id; } String getNameOfMonster() { return nameOfMonster; } void setNameOfMonster(String nameOfMonster) {
  • 5. this.nameOfMonster = nameOfMonster; } String getLocation() { return location; } void setLocation(String location) { this.location = location; } int getNumOfVictims() { return numOfVictims; } void setNumOfVictims(int numOfVictims) { this.numOfVictims = numOfVictims; } String getDate(){ return month + "/" + day + "/" + year; } void setDate(String date){ String arr[] = date.split("/"); this.day = Integer.parseInt(arr[1]); this.month = Integer.parseInt(arr[0]); this.year = Integer.parseInt(arr[2]); } public String toString(){ return "Attack # " + id + "occurred on " + getDate() + ". " + nameOfMonster + "attacked " + location + ", resulting in " + numOfVictims + " tragic fatalities."; } } // AttackMonitor.java import java.util.ArrayList; import javax.swing.JOptionPane; public class AttackMonitor{ ArrayList attacks = new ArrayList(); void input(){ String nameOfMonster, location, date;
  • 6. int id, numOfVictims; nameOfMonster = JOptionPane.showInputDialog("Enter the name of the monster"); location = JOptionPane.showInputDialog("Enter the location of attack"); date = JOptionPane.showInputDialog("Enter the date of attack"); id = Integer.parseInt(JOptionPane.showInputDialog("Enter the id of attack")); numOfVictims = Integer.parseInt(JOptionPane.showInputDialog("Enter the number of victims")); MonsterAttack temp = new MonsterAttack(id, date, nameOfMonster, location, numOfVictims); attacks.add(temp); } void display(){ for(int i = 0; i < attacks.size(); i++){ System.out.println(attacks.get(i)); } } void delete(){ display(); int id = Integer.parseInt(JOptionPane.showInputDialog("Enter the id of attack to delete")); int i; for(i = 0; i < attacks.size(); i++){ if(attacks.get(i).getId() == id){ break; } } if(i != attacks.size()) attacks.remove(i); } void monitor(){ int choice = Integer.parseInt(JOptionPane.showInputDialog("Enter 1 for adding new attack, 2 for displaying attacks, 3 for deleting an attack, any other number to exit")); switch (choice) { case 1: input(); break; case 2: display();