| | |
Please help
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
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. . .
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)
class LectureTheatre { public static void main(String[] arguments) { private int maxOccupancy; private int layoutStyle; private String lectureTheatreName; } } }
•
•
•
•
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)
class LectureTheatre { public static void main(String[] arguments) { private int maxOccupancy; private int layoutStyle; private String lectureTheatreName; } } }
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.
•
•
•
•
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)
class LectureTheatre { public static void main(String[] arguments) { private int maxOccupancy; private int layoutStyle; private String lectureTheatreName; } } }
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:
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.
ie:
java Syntax (Toggle Plain Text)
class LectureTheaterDriver { public static void main(String[] args) { LectureTheater lt = new LectureTheater(value1, value2, value3); } } class LectureTheater { /* Declare global variables HERE */ private int maxOccupancy; private int layoutStyle; private String lectureTheatreName; /* Constructor */ public LectureTheater(var1 value, var2 value, var3 value) { /* Whatever you need to do in constructor */ } }
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.
•
•
•
•
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):
![]() |
Other Threads in the Java Forum
- Previous Thread: Beginner needs help with 2d array
- Next Thread: GUI question
| Thread Tools | Search this Thread |
911 actionlistener addressbook android api append applet application array arrays automation binary bluetooth character chat class classes client code component consumer csv database desktop eclipse error exception fractal ftp game givemetehcodez graphics gui html ide image input integer j2me japplet java javaarraylist javac javaee javaprojects jmf jni jpanel julia linked linux list loop mac map method methods mobile netbeans newbie objects online oriented panel print printf problem program programming project projects properties recursion replaydirector reporting researchinmotion robot rotatetext rsa scanner screen se server set size sms sort sql string swing template test threads time title tree ubuntu update windows working






