This is the program we were assigned to do
(Project: Emergency Response Class) The North American emergency response service, 9-1-1, connects callers to a local Public Service Answering Point (PSAP). Traditionally, the PSAP would ask the caller for identification information—including the caller’s address, phone number and the nature of the emergency, then dispatch the appropriate emergency responders (such as the police, an ambulance or the fire department). Enhanced 9-1-1 (or E9-1-1) uses computers and databases to determine the caller’s physical address, directs the call to the nearest PSAP, and displays the caller’s phone number and address to the call taker. Wireless Enhanced 9-1-1 provides call takers with identification information for wireless calls. Rolled out in two phases, the first phase required carriers to provide the wireless phone number and the location of the cell site or base station transmitting the call. The second phase required carriers to provide the location of the caller (using technologies such as GPS). To learn more about 9-1-1, visit www.fcc.gov/pshs/services/911-services/Welcome.html and people.howstuffworks.com/9-1-1.htm.

An important part of creating a class is determining the class’s attributes (instance variables). For this class design exercise, research 9-1-1 services on the Internet. Then, design a class called Emergency that might be used in an object-oriented 9-1-1 emergency response system. List the attributes that an object of this class might use to represent the emergency. For example, the class might include information on who reported the emergency (including their phone number), the location of the emergency, the time of the report, the nature of the emergency, the type of response and the status of the response. The class attributes should completely describe the nature of the problem and what’s happening to resolve that problem.

How would I do something where you can input the problem either as for example, "Robbery" or "robbery". And I started the code but only could get the variables. Does it look like I am on the right track? If not could someone give me a general idea or pseudocode on how to set only the variables because I'm sure I can figure out the rest from there. I am still learning java so I am still at newbie level.

The variable I got so far.

import java.util.*;
import java.text.*;

    public class Emergency {
    DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy hh:mm:ss a");
           //get current date time with Date()
    Date curDate = new Date();
          // System.out.println(dateFormat.format(date));

           //get current date time with Calendar()
    Calendar cal = Calendar.getInstance();
          // System.out.println(dateFormat.format(cal.getTime()));
    String fullName;
    String City;
    String homeAddress;
    String zipCode;
    String phoneNumber;
    }

Thanks!

Well, for 30+ years I am a professional software engineer. Before that, when my wife was in graduate school, I was an emergency response volunteer EMT and rescue worker for the US Civil Defense. So, I do know something about what you are trying to do.

  1. Break the problem down into smaller bits. What are the items you need to track?
  2. Consider how they are related.

The date stuff is ancillary. Use a static/constant for the date format. That doesn't have much to do with the 911 call, other than how to present the date/time to a user.

Calendar? Why? Doesn't the current date encapsulate that?

You need a couple of support classes, which might be sub-classes of "Emergency", but honestly, that is stretching it a bit. You need a class for "reporting entity", data for "type of emergency" - an enum may (or may not) be appropriate for that information, responding service (may, or may not be another class), location of the emergency, severity and type of the emergency (life-threatening, property damage, etc), and the list goes on.

So, you need to clearly think about all the information this needs to encapsulate, and which parts of that are best reflected by local data entities, and which of those entities are complex enough to have their own class.

You have more work to do! Work on that, and then report back with what you have and we can help you move forward.

Alright so the variables I have just keep them but make a subclass that calls for them? Also, for the info I would make the user input that? And sorry if I'm asking the same thing or obvious questions. I'm not asking for anyone to do my work :) I just like being able to understand and get a general idea.

Edited 3 Years Ago by ZombieKnight93

For the information yes, it will be user input. You can use the scanner for instance
for instance if you defined variable name as n

System.out.println("Please enter your name");
String n = scan.next();

then just make sure whatever you call your array, you're having it print out at the end to display the information you entered. since you'll have subclasses, and using inheritance most likely use the String toString

Zombie, you are asking the right questions. Post an updated set of classes/code to "reflect" the situation and I will comment further, and help you smooth out the rough edges.

  1. You have an entitiy called "Emergency".
  2. You have another entity called "Reporting Entity".
  3. You have information about the type of the emergency, including the severity (life-threatening or not).
    etc.

So, start working on the details. Those we can help you refine.

Rubberman, I'll get right on the coding as soon as I get back from work. But I just want to ask, would it be better to make a switch statement and have the user choose the number that corresponds with the nature of the emergency and severity or have them just type it out and press a number (1 not severe to 5 severe) for the severity?

Alright here is what I did so far. Does it look like I did more work than I need(ed) to? Because I'm not sure.

Main class:

        import java.util.*;
        import java.text.*;

        public class Emergency {
        DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy hh:mm:ss a");
        Date curDate = new Date();
        Calendar cal = Calendar.getInstance();
        private String fullName;
        private String address;
        private String phoneNumber;
        private String emergencyType;
        private String severityLevel;
        private String responseType;
        private String statusType;

        public Emergency(String fName, String location, String phone, String emergency, String severity, 
                String response, String status){
            fullName = fName;
            address = location;
            phoneNumber = phone;
            emergencyType = emergency;
            severityLevel = severity;
            responseType = response;
            statusType = status;
        }
        Emergency(){

        }
        public void setFullName(String fullName){
            this.fullName = fullName;
         }
        public String getFullName(){
            return fullName;
        }
        public void setAddress(String address){

            }
        public String getAddress(){
            return address;
        }
        public void setPhoneNumber(String phoneNumber){

        }
        public String getPhoneNumber(){
            return phoneNumber;
        }
        public void setEmergencyType(String emergencyType){

        }
        public String getEmergencyType(){
            return emergencyType;
        }
        public void setSeverityLevel(String severityLevel){

        }
        public String getSeverityLevel(){
            return severityLevel;
        }

        public String getResponseType(){
            return "Alright, we have alerted someone about your emergency!";
        }
        public String statusType(){
            return statusType();
        }
        }

Is there a way I can make it so depending on the type of emergency the status type will be different (e.g. inputting injury and the status says an ambulance is on its way or if you input robbery the status says a poilce car is on its way)?

Subclass:

        import java.util.Scanner;

        public class Emergency_Report {
        public static void main(String[] args) {
           Scanner input = new Scanner(System.in);
             String fullName;
             String address;
             String phoneNumber;
             String emergencyType;
             String severityLevel;
             String responseType;
             String statusType;

             Emergency emergencyInfo = new Emergency();
             System.err.println("Emergency Report Information: /n");
             System.out.println("What is your name?: " + emergencyInfo.getFullName());
             System.out.println("Where are you located?: " + emergencyInfo.getAddress());
             System.out.println("What is your phone number?: "+ emergencyInfo.getPhoneNumber());
             System.out.println("What is the nature of your emergency?: " + emergencyInfo.getEmergencyType());
             System.out.println("What is the severity of your emergency?: " + emergencyInfo.getSeverityLevel());
        }
        }

Edited 3 Years Ago by ZombieKnight93

This article has been dead for over six months. Start a new discussion instead.