Create a class roomoccupancy that can be used to record

Assignment Help Database Management System
Reference no: EM13894786

1. We created in class a Person class to represent a person. The class has instance variables for a person's name, which is a string, and an integer age. These variables are name and age, respectively.

a. Write a default constructor for Person that sets name to the string "No name yet" and age to zero.

b. Write a second constructor for Person that sets name to a given string and age to a given age.

c. Write a static method createAdult() for Person that returns a special instance of this class. The instance represents a generic adult and has the name "An adult" and the age 21.

2. Create a class RoomOccupancy that can be used to record the number of people in the rooms of a building. The class has the attributes

• numberInRoom-the number of people in a room
• totalNumber-the total number of people in all rooms as a static variable

The class has the following methods:

• addOneToRoom-adds a person to the room and increases the value of totalNumber

• removeOneFromRoom-removes a person from the room, ensuring that numberInRoom does not go below zero, and decreases the value of totalNumber as needed

• getNumber-returns the number of people in the room

• getTotal-a static method that returns the total number of people

3. Define a class called Counter. An object of this class is used to count things, so it records a count that is a nonnegative whole number. Include methods to set the counter to 0, to increase the count by 1, and to decrease the count by 1. Be sure that no method allows the value of the counter to become negative. Also include an accessor method that returns the current count value, as well as a method that displays the count on the screen. Do not define an input method. The only method that can set the counter is the one that sets it to zero.

Reference no: EM13894786

Questions Cloud

What were the consequences to adding 17 thamendment : what were the consequences (both positive and negative) to adding the 17th amendment to the Constitution? Argue whether or not the changes presented by this amendment were consistent with the intent of the Founding Fathers when they wrote the Cons..
What is system interface testing? : What is System Interface testing?
Describe the characteristics of your ideal computer : If cost were not an issue, describe the characteristics of your ideal computer. What would you use it for? Would you choose a handheld, portable, desktop, or workstation computer? Why?
Following will have positive signs and which : Which of the following will have positive signs and which will have negative ones:
Create a class roomoccupancy that can be used to record : Create a class RoomOccupancy that can be used to record the number of people in the rooms of a building
Briefly describe moore law. what are the implications : Briefly describe Moore Law. What are the implications of this law? Are there any practical limitations to Moore Law?
Can you do a survey paper on wavelet and subband coding : Can you do a survey paper on Wavelet and Subband Coding - I need 10 pages and I will provide the references.
Present your well-written self-reflection : Present your well-written self-reflection
What is a relationship in which one organism benefits : What is a relationship in which one organism benefits and the other organism is neither helped nor harmed?

Reviews

Write a Review

Database Management System Questions & Answers

  Knowledge and data warehousing

Design a dimensional model for analysing Purchases for Adventure Works Cycles and implement it as cubes using SQL Server Analysis Services. The AdventureWorks OLTP sample database is the data source for you BI analysis.

  Design a database schema

Design a Database schema

  Entity-relationship diagram

Create an entity-relationship diagram and design accompanying table layout using sound relational modeling practices and concepts.

  Implement a database of courses and students for a school

Implement a database of courses and students for a school.

  Prepare the e-r diagram for the movie database

Energy in the home, personal energy use and home energy efficiency and Efficient use of ‘waste' heat and renewable heat sources

  Design relation schemas for the entire database

Design relation schemas for the entire database.

  Prepare the relational schema for database

Prepare the relational schema for database

  Data modeling and normalization

Data Modeling and Normalization

  Use cases perform a requirements analysis for the case study

Use Cases Perform a requirements analysis for the Case Study

  Knowledge and data warehousing

Knowledge and Data Warehousing

  Stack and queue data structure

Identify and explain the differences between a stack and a queue data structure

  Practice on topic of normalization

Practice on topic of Normalization

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd