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 4 of 4

Thread: Class won't compile throwing 25 error messages totally confused(included error messages and demoprogram created object)

  1. #1
    Junior Member
    Join Date
    Oct 2013
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Class won't compile throwing 25 error messages totally confused(included error messages and demoprogram created object)

    /**

    Creating project3Morris class

    */

    //Fields

    public class Project3Morris
    {
    private int vacantRooms;
    private int numBuildings;
    private int numRoomsFloor;
    private int totalRooms;
    private int numOccupiedRooms;
    private double occupancyRate;
    private int numFloors;

    }

    //Constructor to accept arguments from user input

    public Project3Morris(int nB, int nF, int nRF, int nOR)
    {
    numBuildings=nB;
    numFloors=nF;
    numRoomsFloor=nRF;
    numOccupiedRooms=nOR;
    }


    /**
    Set numBuilding method sets the number of buildings
    @param nB The number of buildings
    */
    public void setNumBuidings(int nB)
    {
    numBuildings=nB;
    }

    /**
    Set numFloors method sets the number of floors
    @param nF The number of floors
    */

    public void setNumFloors(int nF)
    {
    numFloors=nF;
    }

    /**
    Set numRoomsFloor method to set num of rooms per floor
    @param nRF The number of rooms per floor
    */

    public void setNumRoomsFloor(int nRF)
    {
    numRoomsFloor=nRF;
    }

    /**
    Set numOccupiedRooms method to set the number of occupied rooms
    @param nOR The number of occupied rooms
    */

    public void setNumOccupiedRooms(int nOR)
    {
    numOccupiedRooms=nOR;
    }

    /**
    getnumBuildings method
    @return The number of buildings
    */

    public int getNumBuildings()
    {
    return numBuildings;
    }

    /**
    getnumFloors method
    @return The number of floors
    */

    public int getNumFloors()
    {
    return numFloors
    }

    /**
    getnumRoomsFloor method
    @return The number of rooms per floor
    */

    public int getNumRoomsFloor()
    {
    return numRoomsFloor
    }

    /**
    getnumOccupiedRooms method
    @return The number of occupied rooms
    */

    public int getNumOccupiedRooms()
    {
    return numOccupiedRooms
    }

    /**
    getvacantRooms method
    @return The product of numRoomsFloor minus numOccupiedRooms
    */

    public int getVacantRooms()
    {
    return numRoomsFloor - numOccupiedRooms;
    }

    /**
    getOccupancyRate method
    @return The product of numOccupiedRooms divided by numRoomsFloor
    */

    public double getOccupancyRate()
    {
    return numOccupiedRooms / numRoomsFloor;
    }

    /**
    gettotalRooms method
    @return The product of numFloors * numRoomsFloor
    */

    public int getTotalRooms()
    {
    return numFloors * numRoomsFloor;
    }

    /**
    gettotalOccupiedRooms method
    @return The product of numOccupiedRooms * numRoomsFloor
    */

    public int getTotalOccupiedRooms()
    {
    return numOccupiedRooms * numRoomsFloor

    }

    }
    __________________________________________________ __________________________________________________

    Project3Morris.java:23: error: class, interface, or enum expected
    public Project3Morris(int nB, int nF, int nRF, int nOR)
    ^
    Project3Morris.java:26: error: class, interface, or enum expected
    numFloors=nF;
    ^
    Project3Morris.java:27: error: class, interface, or enum expected
    numRoomsFloor=nRF;
    ^
    Project3Morris.java:28: error: class, interface, or enum expected
    numOccupiedRooms=nOR;
    ^
    Project3Morris.java:29: error: class, interface, or enum expected
    }
    ^
    Project3Morris.java:36: error: class, interface, or enum expected
    public void setNumBuidings(int nB)
    ^
    Project3Morris.java:39: error: class, interface, or enum expected
    }
    ^
    Project3Morris.java:46: error: class, interface, or enum expected
    public void setNumFloors(int nF)
    ^
    Project3Morris.java:49: error: class, interface, or enum expected
    }
    ^
    Project3Morris.java:56: error: class, interface, or enum expected
    public void setNumRoomsFloor(int nRF)
    ^
    Project3Morris.java:59: error: class, interface, or enum expected
    }
    ^
    Project3Morris.java:66: error: class, interface, or enum expected
    public void setNumOccupiedRooms(int nOR)
    ^
    Project3Morris.java:69: error: class, interface, or enum expected
    }
    ^
    Project3Morris.java:76: error: class, interface, or enum expected
    public int getNumBuildings()
    ^
    Project3Morris.java:79: error: class, interface, or enum expected
    }
    ^
    Project3Morris.java:86: error: class, interface, or enum expected
    public int getNumFloors()
    ^
    Project3Morris.java:96: error: class, interface, or enum expected
    public int getNumRoomsFloor()
    ^
    Project3Morris.java:106: error: class, interface, or enum expected
    public int getNumOccupiedRooms()
    ^
    Project3Morris.java:116: error: class, interface, or enum expected
    public int getVacantRooms()
    ^
    Project3Morris.java:119: error: class, interface, or enum expected
    }
    ^
    Project3Morris.java:126: error: class, interface, or enum expected
    public double getOccupancyRate()
    ^
    Project3Morris.java:129: error: class, interface, or enum expected
    }
    ^
    Project3Morris.java:136: error: class, interface, or enum expected
    public int getTotalRooms()
    ^
    Project3Morris.java:139: error: class, interface, or enum expected
    }
    ^
    Project3Morris.java:146: error: class, interface, or enum expected
    public int getTotalOccupiedRooms()
    ^
    25 errors

    ----jGRASP wedge2: exit code for process is 1.
    ----jGRASP: operation complete.
    __________________________________________________ __________________________________________________

    //Create an instance of project3Morris
    //passing the data that was entered as arguments
    //to the constructor
    Project3Morris number = new Project3Morris(buildNum, floorNum, roomFloor, occupiedRooms);


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Class won't compile throwing 25 error messages totally confused(included error messages and demoprogram created object)

    Please read the Announcement topic at the top of the sub-forum to learn how to post code in code or highlight tags and other useful info for newcomers.

  3. #3
    Member GoodbyeWorld's Avatar
    Join Date
    Jul 2012
    Location
    Hidden command post deep within the bowels of a hidden bunker somewhere under a nondescrip building
    Posts
    161
    My Mood
    Stressed
    Thanks
    14
    Thanked 25 Times in 25 Posts

    Default Re: Class won't compile throwing 25 error messages totally confused(included error messages and demoprogram created object)

    You're likely having too many brackets or brackets not in the right spot.

    public class Project3Morris
    {
    private int vacantRooms;
    private int numBuildings;
    private int numRoomsFloor;
    private int totalRooms;
    private int numOccupiedRooms;
    private double occupancyRate;
    private int numFloors;

    } <---------------------------


    That ends your class. You're other stuff is outside the class, and in Java you can't have anything outside of a class (or enum) structure (except for package declarations and imports and comments.)

    Get rid of that bracket that the arrow points to and see if things improve.

  4. #4
    Junior Member
    Join Date
    Oct 2013
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Class won't compile throwing 25 error messages totally confused(included error messages and demoprogram created object)

    Thank you that was the problem I figured it out when I started removing code before I read this.

Similar Threads

  1. [SOLVED] Learning OOP; Gettin error messages i cant explain.
    By E.K.Virtanen in forum Object Oriented Programming
    Replies: 2
    Last Post: March 20th, 2013, 11:47 AM
  2. Getting error messages with my javafx video player
    By sharksaw40 in forum What's Wrong With My Code?
    Replies: 11
    Last Post: July 24th, 2012, 01:27 AM
  3. Help needed to figure out why I keep getting error messages in Eclipse
    By RookieCodeWriter in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 18th, 2012, 11:31 AM
  4. Code won't compile, but can't find the error....
    By RockDoc in forum What's Wrong With My Code?
    Replies: 1
    Last Post: January 29th, 2012, 02:09 AM
  5. Error Messages Best Practices
    By Dalek_Supreme in forum Java Theory & Questions
    Replies: 0
    Last Post: April 1st, 2011, 07:22 PM