Results 1 to 3 of 3
- 11-23-2007, 06:02 AM #1
Member
- Join Date
- Nov 2007
- Posts
- 38
- Rep Power
- 0
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 -
im not exactly sure what i have to do here..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.
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.
- 11-23-2007, 07:46 AM #2
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.
Then in your main method: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(); }
Java Code:HotelRx hotel = new HotelRx(3); System.out.println("hotel = " + hotel);
- 11-23-2007, 11:24 AM #3
Member
- Join Date
- Nov 2007
- Posts
- 38
- Rep Power
- 0
Similar Threads
-
Help me ...urgent!
By googgoo in forum New To JavaReplies: 7Last Post: 04-05-2008, 08:46 AM -
Paper,Scissor,Rock If then Statements
By Alberto in forum New To JavaReplies: 2Last Post: 02-11-2008, 11:18 PM -
Broken korean characters Urgent help needed!
By priyap3 in forum JavaServer Pages (JSP) and JSTLReplies: 0Last Post: 01-14-2008, 09:40 AM -
please help urgent
By ananas7777 in forum AWT / SwingReplies: 2Last Post: 12-25-2007, 08:30 AM -
urgent help needed for [application-${environment}.properties]
By deepman in forum Advanced JavaReplies: 0Last Post: 08-14-2007, 09:31 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks