Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: I don't undertsand why it is not recognizing the dispReport() method on line 67?

  1. #1
    Junior Member
    Join Date
    Aug 2023
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default I don't undertsand why it is not recognizing the dispReport() method on line 67?

    import java.util.ArrayList;
    import java.util.Collection;

    import javax.swing.JOptionPane;


    public class Hotel {
    static ArrayList<Hotel> ReservationList= new ArrayList<Hotel>();
    static String input="";

    public static void main(String[] args) {
    int selection = 0;
    int start = 0;
    int foundAt = -1;
    String searchReservation="";
    start=JOptionPane.showConfirmDialog(null,"Do you wish to reserve a hotel room?", null, JOptionPane.YES_NO_OPTION);
    if (start==JOptionPane.NO_OPTION)
    JOptionPane.showMessageDialog(null, "Thank you for visiting!");
    else
    while(selection!=4){
    selection = menu();
    switch(selection) {

    case 1: Reservation reservation = new Reservation();
    reservation.addReservation();
    ReservationList.add(null);

    break;

    case 2: if(ReservationList.isEmpty())
    JOptionPane.showMessageDialog(null,
    "database is empty! goback and add records.");
    else
    dispAllReservations();
    break;



    }



    }



    }//end main
    public static int menu() {
    int selection=0;

    String Prompt= "-1-Add a reservation\n" +
    "-2-Show a reservation\n" +
    "-3-Quit program\n" +
    "\tEnter selection 1-3: ";
    input=JOptionPane.showInputDialog(Prompt);
    selection = Integer.parseInt(input);
    return selection;


    }


    public static void dispAllReservations()
    {
    for (int i = 0; i < ReservationList.size(); i++)
    {
    ReservationList.get(i).dispReport();
    }//end for i
    }//end dispAllBackflows





    }





    //=================================================
    class Reservation{
    String ReservationNo;
    String firstName;
    String lastName;
    String roomType;
    String Email;
    String phoneNumber;
    String numberOfPeople;
    String zipCode;
    String input="";

    Reservation()
    {
    ReservationNo="";
    firstName="";
    lastName="";
    roomType="";
    Email="";
    phoneNumber="";
    numberOfPeople="";
    zipCode="";

    }
    Reservation(String ReservationNo,String firstName, String roomType,String Email,
    String phoneNumber,String numberOfPeople,String zipCode,String lastName)
    {
    this.ReservationNo=ReservationNo;
    this.firstName=firstName;
    this.lastName=lastName;
    this.roomType=roomType;
    this.Email=Email;
    this.phoneNumber=phoneNumber;
    this.numberOfPeople=numberOfPeople;
    this.zipCode=zipCode;

    }

    void addReservation() {
    input = JOptionPane.showInputDialog("Enter your first name:");
    firstName=input;

    input = JOptionPane.showInputDialog("Enter your last name:");
    lastName=input;

    input = JOptionPane.showInputDialog("Enter your room type:");
    roomType=input;

    input = JOptionPane.showInputDialog("Enter your email:");
    Email=input;

    input = JOptionPane.showInputDialog("Enter your phone number:");
    phoneNumber=input;

    input = JOptionPane.showInputDialog("How many people will be staying:");
    numberOfPeople=input;

    input = JOptionPane.showInputDialog("Enter your zip code:");
    zipCode=input;

    }


    void dispReport() {
    JOptionPane.showMessageDialog(null, "First Name" + firstName + "\n" +
    "Last Name " + lastName + "\n" +
    "Room Type " + roomType + "\n" +
    "Email " + Email + "\n" +
    "Phone " + phoneNumber + "\n" +
    "Guest number" + numberOfPeople + "\n" +
    "zipCode" + zipCode + "\n"
    );

    }

    }

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: I don't undertsand why it is not recognizing the dispReport() method on line 67?

    Please copy the full text of the compiler error message and past it here.

    Please edit your post and wrap your code with code tags:

    [code]
    **YOUR CODE GOES HERE**
    [/code]

    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Program not recognizing string sentinel
    By BethM in forum What's Wrong With My Code?
    Replies: 4
    Last Post: June 13th, 2014, 03:23 AM
  2. [SOLVED] Beginner // switch not recognizing upper case Q
    By Christian_Doucet in forum What's Wrong With My Code?
    Replies: 2
    Last Post: April 2nd, 2014, 10:02 PM
  3. [SOLVED] Cmd not recognizing a different Dir / ClassPath / FilePath / Environment
    By Andrew R in forum What's Wrong With My Code?
    Replies: 11
    Last Post: August 19th, 2013, 07:53 AM
  4. Eclipse not recognizing my method for class.
    By jerryg in forum What's Wrong With My Code?
    Replies: 3
    Last Post: March 9th, 2012, 06:52 PM
  5. Replies: 10
    Last Post: September 16th, 2011, 07:49 PM