e rooms are then automatically created and added to the dormitory, numbered from 1, 2, 3, and so on, representing the room number. Once the room number is assigned to the created room, this information cannot be edited anymore. *The dormitory can accept guests into a given room number. Each guest has a name and nationality. If the capacity is full or an invalid room number is provided, the guest will not be added and this method returns false. Otherwise, this method returns true. *The dormitory also has a method to return the guests in a given room number. If an invalid room number is provided, the method will return null. *Private instantiation variable(attributes) in the two classes are allowed and not public. The guest class(we can make use of) is already coded like this-> import java.util.*; class Main implements Comparator { @Override public int compare(meeting o1, meeting o2) { if (o1.end < o2.end) { return -1; } else if (o1.end >

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%
I need help in coding these two classes(dorm and room) in JAVA from the following information-> *A dormitory has a name and has several rooms. When a dormitory is built, the name and the number of rooms should be provided. In some cases, the maximum capacity of the rooms is also provided. If there is no maximum capacity set, each room can accommodate at most 6 guests. *The rooms are then automatically created and added to the dormitory, numbered from 1, 2, 3, and so on, representing the room number. Once the room number is assigned to the created room, this information cannot be edited anymore. *The dormitory can accept guests into a given room number. Each guest has a name and nationality. If the capacity is full or an invalid room number is provided, the guest will not be added and this method returns false. Otherwise, this method returns true. *The dormitory also has a method to return the guests in a given room number. If an invalid room number is provided, the method will return null. *Private instantiation variable(attributes) in the two classes are allowed and not public. The guest class(we can make use of) is already coded like this-> import java.util.*; class Main implements Comparator { @Override public int compare(meeting o1, meeting o2) { if (o1.end < o2.end) { return -1; } else if (o1.end > o2.end) return 1; return 0; } } class meeting { int start; int end; int pos; meeting(int start, int end, int pos) { this.start = start; this.end = end; this.pos = pos; } } class GFG { public static void maxMeeting(ArrayList al, int s) { ArrayList m = new ArrayList<>(); int time_limit = 0; Main mc = new Main(); Collections.sort(al, mc); m.add(al.get(0).pos); time_limit = al.get(0).end; for (int i = 1; i < al.size(); i++) { if (al.get(i).start > time_limit) { m.add(al.get(i).pos); time_limit = al.get(i).end; } } for (int i = 0; i < m.size(); i++) System.out.print(m.get(i) + 1 + " "); } public static void main(String[] args) { int s[] = { 1, 3, 0, 5, 8, 5 }; int f[] = { 2, 4, 6, 7, 9, 9 }; ArrayList meet = new ArrayList<>(); for (int i = 0; i < s.length; i++) meet.add(new meeting(s[i], f[i], i)); maxMeeting(meet, meet.size()); } }
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Math class and its different methods
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education