| | |
Please help
![]() |
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 |
-xlint add android api applet application applications array arrays automation bank bi binary blackberry bluetooth chat class client code compile compiler component database development digit eclipse equation error event fractal freeze functiontesting game gameprogramming givemetehcodez graphics gui health html hyper ide idea image infinite input int integer j2me java javame javaprojects jetbrains jni jpanel jtable julia learningresources linux list login loop main map method methods mobile myregfun netbeans newbie nonstatic notdisplaying pearl problem program programming project qt recursion scanner screen scrollbar server set sms sort sorting spamblocker sql sqlserver string superclass swing system text-file thread threads tree variablebinding windows xor






