1. Theatre management
Create a class Theatre with the below attributes:
theatreNumber- int
theatreName - String
theatreCapacity - int
theatreRating - int
theatre Type - String
The above attributes should be private, write getters, setters, and parameterized constructor as required.
Create a class Solution with the main method.
Implement two static methods -getTheatreCapacity and getSecond Lowest TheatreRating in Solution class.
getTheatreCapacity method:
This method will take an array of Theatre objects and an int value as input parameters. The method will return the capacity of the Theatre from an array of Theatre objects for the given Theatre Number(int parameter passed).
If no theatre with the given theatreNumber is present in the array of Theatre objects, then the method should return 0.
getSecond Lowest Theatre Rating method:
This method will take array of Theatre objects and a String value as input parameters. It will return the Theatre object with the
second-lowest rating from the given array of objects for the given Theatre type(String parameter passed).
If no theatre with the above condition is present in the array of Theatre objects, then the method should return null.
Note: No two Theatre will have the same rating and capacity.
All the searches should be case insensitive.
The above-mentioned static methods should be called from the main method.
For getTheatreCapacity method - The main method should print the returned capacity as It is if the returned value is greater than Car
16
11
12
13
14
15
16
17
18
Test
it should print "Theatre Number is incorrect".
For getSecondLowest Theatre Rating method -
The main method should print the theatreName and theatreRating from the returned Theatre object if the returned value is not null. If the returned value is null then it should print "No such Theatre".
Before calling these static methods in main, use Scanner object to read the values of four Theatre objects referring to attributes in theabove-mentioned attribute sequence. Next, read the value of the int parameter and a String parameter for capturing Theatre Number and Theatre Type respectively.
Consider below sample input and output:
TestCase1:
Input:
101
Star
600
5
Movie
102
Luxury
500
4
Movie
103
Vinayak
200
2
Movie
104
SelectCityWalk
300
3
Single
103
Movie
Sample Output2:
200
Luxury
4
TestCase2:
Input:
101
Star
600
5
Single
102
Luxury
500
4
Movie
103
Vinayak
200
2
Movie
104
SelectCityWalk
300
3
Single
103
Movie
110
Drama
Sample Output2:
Theatre Number is incorrect
No such Theatre
technical explaination of the code:
Code for Practise
0 Comments