Please help

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Oct 2008
Posts: 7
Reputation: AdventureX is an unknown quantity at this point 
Solved Threads: 0
AdventureX's Avatar
AdventureX AdventureX is offline Offline
Newbie Poster

Please help

 
0
  #1
Nov 19th, 2008
We have been given a task to do the following:-

Write a class LectureTheatre that has the following attributes (properties):

lectureTheatreName / maxOccupancy / layoutStyle (the lecture theatre may be either flat or tiered)

For example:-
lectureTheatreName : Frankland LT ... or ... Fylde LT2 ... or ... George Fox LT1
maxOccupancy : 145 ... 45 ... 350
layoutStyle : tiered ... flat ... tiered

- Attributes should be considered to be Strings or integers, as appropriate
- All attributes should be considered to be private to the class
- Include a javadoc comment for each attribute

This is the start of the class - is this going along the right lines? We do not know where to go from here. . .

  1. class LectureTheatre {
  2. public static void main(String[] arguments) {
  3.  
  4. private int maxOccupancy;
  5. private int layoutStyle;
  6. private String lectureTheatreName;
  7.  
  8.  
  9. }
  10.  
  11.  
  12. }
  13. }
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 706
Reputation: stultuske is a jewel in the rough stultuske is a jewel in the rough stultuske is a jewel in the rough 
Solved Threads: 84
stultuske's Avatar
stultuske stultuske is offline Offline
Master Poster

Re: Please help

 
0
  #2
Nov 19th, 2008
Originally Posted by AdventureX View Post
We have been given a task to do the following:-

Write a class LectureTheatre that has the following attributes (properties):

lectureTheatreName / maxOccupancy / layoutStyle (the lecture theatre may be either flat or tiered)

For example:-
lectureTheatreName : Frankland LT ... or ... Fylde LT2 ... or ... George Fox LT1
maxOccupancy : 145 ... 45 ... 350
layoutStyle : tiered ... flat ... tiered

- Attributes should be considered to be Strings or integers, as appropriate
- All attributes should be considered to be private to the class
- Include a javadoc comment for each attribute

This is the start of the class - is this going along the right lines? We do not know where to go from here. . .

  1. class LectureTheatre {
  2. public static void main(String[] arguments) {
  3.  
  4. private int maxOccupancy;
  5. private int layoutStyle;
  6. private String lectureTheatreName;
  7.  
  8.  
  9. }
  10.  
  11.  
  12. }
  13. }
without a doubt you received error messages trying to compile this?
remove the 'private' in front of your variables, or declare them outside your method.
since you have to declare them private for the class, and not only for the method, I suggest you to declare them in the class, not in the main method.

it is my belief that you will have gone over the basics OO concepts before been given such a task, so I'd recommend you to put in a bit more effort, improve your code and write more (since you'll need more) and post that here if you run into problems.
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 4,477
Reputation: Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of 
Solved Threads: 514
Moderator
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Industrious Poster

Re: Please help

 
0
  #3
Nov 19th, 2008
Originally Posted by AdventureX View Post
This is the start of the class - is this going along the right lines? We do not know where to go from here. . .

  1. class LectureTheatre {
  2. public static void main(String[] arguments) {
  3.  
  4. private int maxOccupancy;
  5. private int layoutStyle;
  6. private String lectureTheatreName;
  7.  
  8.  
  9. }
  10.  
  11.  
  12. }
  13. }
No. Take main() out altogether at this point. It has nothing at all to do with the class itself.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 16
Reputation: vee_liang is an unknown quantity at this point 
Solved Threads: 1
vee_liang vee_liang is offline Offline
Newbie Poster

Re: Please help

 
0
  #4
Nov 20th, 2008
what is the expected output of that project actually? commonly i would make a 'setter-getter' class or object definition class for the Lecture Theater.
Vee Liang
To be right, first you have to know what wrong is.
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 706
Reputation: stultuske is a jewel in the rough stultuske is a jewel in the rough stultuske is a jewel in the rough 
Solved Threads: 84
stultuske's Avatar
stultuske stultuske is offline Offline
Master Poster

Re: Please help

 
0
  #5
Nov 20th, 2008
Originally Posted by vee_liang View Post
commonly i would make a 'setter-getter' class or object definition class for the Lecture Theater.
you mean create an object? since that's his assignment, I'm pretty sure he 'll eventually do that.
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 37
Reputation: bondo is an unknown quantity at this point 
Solved Threads: 0
bondo's Avatar
bondo bondo is offline Offline
Light Poster

Re: Please help

 
0
  #6
Nov 20th, 2008
I don't know if your goal is to utilize object-oriented programming or not, but typically I would have 2 separate classes (probably in 2 separate file). One would be the "driver" file that contained main(), and the other would be the object class.

ie:

  1. class LectureTheaterDriver
  2. {
  3. public static void main(String[] args)
  4. {
  5. LectureTheater lt = new LectureTheater(value1, value2, value3);
  6. }
  7. }
  8.  
  9. class LectureTheater
  10. {
  11. /* Declare global variables HERE */
  12. private int maxOccupancy;
  13. private int layoutStyle;
  14. private String lectureTheatreName;
  15.  
  16. /* Constructor */
  17. public LectureTheater(var1 value, var2 value, var3 value)
  18. {
  19. /* Whatever you need to do in constructor */
  20. }
  21. }

Then, from main in LectureTheaterDriver, you would make method calls to any other public methods inside the LectureTheater object you created.

In the end, main winds up being very small with little to no processing and your object does all the work.

That's how I would get started on it anyways.

You might want to look up constructors, getters & setters (which are also referred to as Accessors and Mutators)

Hope that's helpful.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 16
Reputation: vee_liang is an unknown quantity at this point 
Solved Threads: 1
vee_liang vee_liang is offline Offline
Newbie Poster

Re: Please help

 
0
  #7
Nov 23rd, 2008
This is the start of the class - is this going along the right lines? We do not know where to go from here. . .
since that line comes...
Vee Liang
To be right, first you have to know what wrong is.
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 706
Reputation: stultuske is a jewel in the rough stultuske is a jewel in the rough stultuske is a jewel in the rough 
Solved Threads: 84
stultuske's Avatar
stultuske stultuske is offline Offline
Master Poster

Re: Please help

 
0
  #8
Nov 23rd, 2008
Originally Posted by bondo
I don't know if your goal is to utilize object-oriented programming or not
Originally Posted by AdventureX
We have been given a task to do the following:-

Write a class LectureTheatre that has the following attributes (properties):
I'm pretty sure that's what they're supposed to do. it would be better for them to first start reading their first chapter instead of skipping class, or just not paying attention, and then sob because they don't understand
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 16
Reputation: vee_liang is an unknown quantity at this point 
Solved Threads: 1
vee_liang vee_liang is offline Offline
Newbie Poster

Re: Please help

 
0
  #9
Nov 23rd, 2008
Originally Posted by stultuske View Post
I'm pretty sure that's what they're supposed to do. it would be better for them to first start reading their first chapter instead of skipping class, or just not paying attention, and then sob because they don't understand
couldn't agree more, fella.
Vee Liang
To be right, first you have to know what wrong is.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the Java Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC