Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6957881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:04:08+00:00 2026-05-27T15:04:08+00:00

I currently have a class Room and a class Hostel which holds rooms =

  • 0

I currently have a class Room and a class Hostel which holds rooms = new ArrayList < Room >();. I then have a BookRoomGUI class.

When a room is added to the arraylist it uses the following constructor:

public Room(int newRoomNo, boolean newRoomEnSuite)
{
    roomNo = newRoomNo;
    roomEnSuite = newRoomEnSuite;
    roomBooking = "Free";
    roomNights = 0;
    roomBooker = "No Booker";
}

In the BookRoomGUI class i have the following JTextFields:

    fields.add(roomnumberJTextField);
    fields.add(bookerJtextField);
    fields.add(nightsJTextField);
    fields.add(peoplenoJTextField);

I am trying to make a method within Hostel which will take the values of these text fields and alter the corresponding variables in the original constructor if the room number matches:

public int makeBooking(int number)
{
  for (Room room : rooms)
  {
     if (number == room.getRoomNo())
     {
         room.setRoomBooker(bookRoom.booker);
     }
  }
}

My question is what should go in the if statement? currently i use booker = bookerJtextField.getText(); to take the text from the text field in BookRoomGUI and setRoomBooker in Room but this does not work and i am presented with

setRoomBooker() in Room cannot be applied to (java.lang.String)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T15:04:09+00:00Added an answer on May 27, 2026 at 3:04 pm

    Make sure you have the following method in Room:

    public void setRoomBooker(String roomBooker) {
        this.roomBooker = roomBooker;
    }
    

    Right now, if you look at the error messege:

    setRoomBooker() in Room cannot be applied to (java.lang.String)

    You can see that your setRoomBooker() method currently is not defined to take a parameter of type java.lang.String (or any parameter at all).

    So, you need to change the definition of that method, for you to be able to do the following:

    room.setRoomBooker(bookRoom.booker); //<-- You are passing it an argument of type String
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a class file with the following enumeration: using System; namespace Helper
I currently have a class where I need accomplish the equivalent of the following
I currently have a class that uses the KeyValuePair with List to store a
i currently have a class that uses bitmap. however it is not serializable due
I have a class Room , and a class World . Currently, I have
I have the following class public class Room { public virtual Guid Id {
I currently have a class which I instantiate when I start my program. The
I currently have a class that uses template arguments. I need an array of
I currently have a class and I'm trying to create an easy GUI to
I currently have a class called clientActivity that contains a finger paintig activity that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.