Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-23-2007, 07:02 AM
Member
 
Join Date: Nov 2007
Posts: 33
dirtycash is on a distinguished road
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 -


Quote:
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.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 11-23-2007, 08:46 AM
Senior Member
 
Join Date: Jul 2007
Posts: 1,189
hardwired is on a distinguished road
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.
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:
Code:
HotelRx hotel = new HotelRx(3); System.out.println("hotel = " + hotel);
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 11-23-2007, 12:24 PM
Member
 
Join Date: Nov 2007
Posts: 33
dirtycash is on a distinguished road
but what would the diagram actually look like?
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help me ...urgent! googgoo New To Java 7 04-05-2008 09:46 AM
Paper,Scissor,Rock If then Statements Alberto New To Java 2 02-12-2008 12:18 AM
Broken korean characters Urgent help needed! priyap3 JavaServer Pages (JSP) and JSTL 0 01-14-2008 10:40 AM
please help urgent ananas7777 AWT / Swing 2 12-25-2007 09:30 AM
urgent help needed for [application-${environment}.properties] deepman Advanced Java 0 08-14-2007 10:31 AM


All times are GMT +3. The time now is 05:56 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org