Create a class called Hospital. A Hospital is described by four pieces of private information as instance variables: the hospital name (String), specialty (String), totalBeds that represents the total number of beds (int), and occupiedBeds (int). Provide a set and a get method for each instance variable. For the setters: if the totalBeds is not positive, it should be set to 500. The occupiedBeds must be positive, and it should not be greater than the totalBeds. Otherwise, it should be set to 0. Your class should have one constructor that properly initializes the three instance variables. In addition, provide the following methods: 1. A method named isFull0 that returns true if all the beds are occupied, and false if there are available beds. 2. A method named getAvailableBeds() that returns 0 if the hospital is full. Otherwise, it returns the number of available beds. Write an application named HospitalTest to test Hospital class. In the HospitalTest do the following: 1. Create a hospital instance with these details: "Al-Seha", "Physiotherapy", totalBeds = 500 and occupiedBeds = 350. %3D %3D 2. Print details of the above hospital and the number of available beds, properly labeled. 3. Create another hospital instance for the Hospital: "Sidra", "Pediatrics", totalBeds = 1000

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
Create a class called Hospital. A Hospital is described by four pieces of private information as
instance variables: the hospital name (String), specialty (String), totalBeds that represents the total
number of beds (int), and occupiedBeds (int).
Provide a set and a get method for each instance variable. For the setters: if the totalBeds is not
positive, it should be set to 500. The occupiedBeds must be positive, and it should not be greater
than the totalBeds. Otherwise, it should be set to 0.
Your class should have one constructor that properly initializes the three instance variables. In
addition, provide the following methods:
1. A method named isFull0 that returns true if all the beds are occupied, and false if there are
available beds.
2. A method named getAvailableBeds() that returns 0 if the hospital is full. Otherwise, it
returns the number of available beds.
Write an application named HospitalTest to test Hospital class. In the HospitalTest do the
following:
1. Create a hospital instance with these details: "Al-Seha", "Physiotherapy", totalBeds = 500
and occupiedBeds = 350.
2. Print details of the above hospital and the number of available beds, properly labeled.
3. Create another hospital instance for the Hospital: "Sidra", "Pediatrics", totalBeds = 1000
and occupiedBeds
500 (yes, the value is negative).
4. Print the name, the totalBeds, and the availableBeds. for this instance.
5. Using a getter and a setter, set the occupiedBeds for Sidra to be half the total number of
beds.
6. Re-print the name and the totalBeds, and the availableBeds of Sidra after setting the
оссирiedBeds.
Transcribed Image Text:Create a class called Hospital. A Hospital is described by four pieces of private information as instance variables: the hospital name (String), specialty (String), totalBeds that represents the total number of beds (int), and occupiedBeds (int). Provide a set and a get method for each instance variable. For the setters: if the totalBeds is not positive, it should be set to 500. The occupiedBeds must be positive, and it should not be greater than the totalBeds. Otherwise, it should be set to 0. Your class should have one constructor that properly initializes the three instance variables. In addition, provide the following methods: 1. A method named isFull0 that returns true if all the beds are occupied, and false if there are available beds. 2. A method named getAvailableBeds() that returns 0 if the hospital is full. Otherwise, it returns the number of available beds. Write an application named HospitalTest to test Hospital class. In the HospitalTest do the following: 1. Create a hospital instance with these details: "Al-Seha", "Physiotherapy", totalBeds = 500 and occupiedBeds = 350. 2. Print details of the above hospital and the number of available beds, properly labeled. 3. Create another hospital instance for the Hospital: "Sidra", "Pediatrics", totalBeds = 1000 and occupiedBeds 500 (yes, the value is negative). 4. Print the name, the totalBeds, and the availableBeds. for this instance. 5. Using a getter and a setter, set the occupiedBeds for Sidra to be half the total number of beds. 6. Re-print the name and the totalBeds, and the availableBeds of Sidra after setting the оссирiedBeds.
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Developing computer interface
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
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