944,005 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 762
  • Java RSS
Nov 19th, 2008
0

Please help

Expand 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. . .

Java Syntax (Toggle Plain Text)
  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. }
Reputation Points: 10
Solved Threads: 0
Newbie Poster
AdventureX is offline Offline
7 posts
since Oct 2008
Nov 19th, 2008
0

Re: Please help

Click to Expand / Collapse  Quote originally posted by AdventureX ...
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. . .

Java Syntax (Toggle Plain Text)
  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.
Reputation Points: 935
Solved Threads: 356
Posting Maven
stultuske is offline Offline
2,505 posts
since Jan 2007
Nov 19th, 2008
0

Re: Please help

Click to Expand / Collapse  Quote originally posted by AdventureX ...
This is the start of the class - is this going along the right lines? We do not know where to go from here. . .

Java Syntax (Toggle Plain Text)
  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.
Moderator
Featured Poster
Reputation Points: 3239
Solved Threads: 839
Posting Genius
Ezzaral is offline Offline
6,761 posts
since May 2007
Nov 20th, 2008
0

Re: Please help

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.
Reputation Points: 25
Solved Threads: 8
Light Poster
vee_liang is offline Offline
38 posts
since Aug 2008
Nov 20th, 2008
0

Re: Please help

Click to Expand / Collapse  Quote originally posted by vee_liang ...
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.
Reputation Points: 935
Solved Threads: 356
Posting Maven
stultuske is offline Offline
2,505 posts
since Jan 2007
Nov 20th, 2008
0

Re: Please help

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:

java Syntax (Toggle Plain Text)
  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.
Reputation Points: 11
Solved Threads: 0
Light Poster
bondo is offline Offline
43 posts
since Apr 2007
Nov 23rd, 2008
0

Re: Please help

Quote ...
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...
Reputation Points: 25
Solved Threads: 8
Light Poster
vee_liang is offline Offline
38 posts
since Aug 2008
Nov 23rd, 2008
0

Re: Please help

Quote originally posted by bondo ...
I don't know if your goal is to utilize object-oriented programming or not
Quote 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
Reputation Points: 935
Solved Threads: 356
Posting Maven
stultuske is offline Offline
2,505 posts
since Jan 2007
Nov 23rd, 2008
0

Re: Please help

Click to Expand / Collapse  Quote originally posted by stultuske ...
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.
Reputation Points: 25
Solved Threads: 8
Light Poster
vee_liang is offline Offline
38 posts
since Aug 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: Beginner needs help with 2d array
Next Thread in Java Forum Timeline: GUI question





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC