Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java

Abe Layee
Abe Layee
8,378 Points

error: missing return statement.

I keep getting the error "missing return statement". However, I checked line 35 and everything seems good. I don't know what I am doing wrong. A little help will be appreciated

import  java.util.*;
import  java.text.*;
import java.io.*;
import java.util.Arrays;


class Hotel {

      private  String name;
      private int rooms;
      private  int booked;
      private  String[] roomTypes = {"Twin","Double", "Suite"};
      public  Hotel() {}


       public  Hotel (String name, int rooms, int booked) {
        super();
        this.name = name;
        this.rooms = rooms;
        this.booked = booked;
    }


    public  void setName (String Name) {
        name = Name;
    }

    public  String getName () {
            return name;
        }


    public int Setroom(int Room){
        rooms = Room;   
    }

    public int getRoom (){
        return rooms;
    }

    public void setBooked (int Booked){
         booked = Booked;
    }


    public int getBooked (){
        return booked;
    }

     public int checkAvailability (){
        return this.rooms - this.booked;
    }

    public  void getRoomTypes (String RoomTypes){
        for(int i = 0; i < roomTypes.length; i++) {

        } 
    }



    public static void main(String[] args){

        Hotel hotel = new Hotel();
        hotel.setName("Hamilton");
        hotel.Setroom(40);
        hotel.setBooked(22);    
    }

}

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! You have this function:

public int Setroom(int Room){
        rooms = Room;   
    }

You've stated that it will return an int, but no value is returned here. If you say it will return something, then it must return something. My guess is that you meant this to simply set a value and return nothing. If so you will need to declare the return type as void.

Hope this helps! :sparkles:

Abe Layee
Abe Layee
8,378 Points

Thank you so much. I was over thinking it too much.