Results 1 to 3 of 3
  1. #1
    dirtycash is offline Member
    Join Date
    Nov 2007
    Posts
    38
    Rep Power
    0

    Default urgent help needed - paper submission.

    as part of my paper submission for coursework based on a software model of a hotel im being asked the following question -


    draw a diagram showing the state of the hotel after the constructor has been invoked
    with a parameter value of 3. To show a state of the object you need to list its fields
    and the value of each of those fields. For reference types, draw an arrow from the field to
    the object it represents. You should also show the state of any Room and Occupier objects that have
    been created.
    im not exactly sure what i have to do here..
    can someone explain it to me?

    i especially dont understand the "showing the state of the hotel after the constructor has been invoked
    with a parameter value of 3" bit of it.
    many of the other questions are phrased this way, so if you could give m some advice on what to do id really appreciate it.

  2. #2
    hardwired's Avatar
    hardwired is offline Senior Member
    Join Date
    Jul 2007
    Posts
    1,576
    Rep Power
    9

    Default

    To show a state of the object you need to list its fields and the value of each of those fields
    The fields are the member variables of the class. You can override the toString method in the Hotel class to write out the state of these member variables.
    Java Code:
        public String toString()
        {
            StringBuilder sb = new StringBuilder();
            sb.append("HotelRx[arrayNewRoom:\n");
            for(int j = 0; j < arrayNewRoom.length; j++) {
                sb.append(arrayNewRoom[j] + "\n");
            }
            sb.append(", totalHotelIncome: " + totalHotelIncome +
                      ", freeRooms: " + freeRooms + "]");
            return sb.toString();
        }
    Then in your main method:
    Java Code:
            HotelRx hotel = new HotelRx(3);
            System.out.println("hotel = " + hotel);

  3. #3
    dirtycash is offline Member
    Join Date
    Nov 2007
    Posts
    38
    Rep Power
    0

Similar Threads

  1. Help me ...urgent!
    By googgoo in forum New To Java
    Replies: 7
    Last Post: 04-05-2008, 08:46 AM
  2. Paper,Scissor,Rock If then Statements
    By Alberto in forum New To Java
    Replies: 2
    Last Post: 02-11-2008, 11:18 PM
  3. Broken korean characters Urgent help needed!
    By priyap3 in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 01-14-2008, 09:40 AM
  4. please help urgent
    By ananas7777 in forum AWT / Swing
    Replies: 2
    Last Post: 12-25-2007, 08:30 AM
  5. Replies: 0
    Last Post: 08-14-2007, 09:31 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •