Java: An Introduction to Problem Solving and Programming (7th Edition)
Java: An Introduction to Problem Solving and Programming (7th Edition)
7th Edition
ISBN: 9780133766264
Author: Walter Savitch
Publisher: PEARSON
bartleby

Concept explainers

bartleby

Videos

Textbook Question
Book Icon
Chapter 9, Problem 10E

Suppose that you are going to create an object used to count the number of people in a room. We know that the number of people in the room can never be negative. Create a RoomCounter class having three public methods:

  • addPerson—adds one person to the room
  • removePerson—removes one person from the room
  • getCount—returns the number of people in the room

If removePerson would make the number of people less than zero, throw a NegativeCounterException.

Blurred answer
Students have asked these similar questions
Can you use it in a scanner so i can copy paste please.    Part 1  A regular triangle is one for which all sides are congruent and all interior angles. Create a class RegularTriangle with a field side (int) Create a constructor which accepts an int parameter and will assign the parameter to field side Create assessor and mutator for this class Create a method getPerimeter() which should return 3*side;   Part 2 in the constructor, add a logic that if the input parameter is less than 5 then set the side to 5, if it is >10 then set the side to 10, otherwise set the side to the input value.   Screenshot final output
Problem: Bugs are simple creatures that only know how to walk towards other bugs. Bugs maintain information about their (x, y) position; by which it can tell if they are standing next to other bugs. Watch the following video: bug movement. Create a java project that simulate bugs movement. You need to write a class “Bug" that models a bug moving along a straight line and it can turn to change its direction counterclockwise (i.e. 90 degree to the left; north → west → south → east → north). In each move, its position changes by one unit in the current direction. Details of the "Bug" class is described below. Your simulator should read information of an unknown number of “Bug" objects from an input file called “Bugs.txt". Each line represents a bug and the initial position and facing direction of this particular bug. Keeping the first bug position as a reference the simulator should move the second bug next to the first bug forming a cluster and its final position and direction should be…
Write a class for a Chicken that also implements your interface. The Chicken’s type will be “chicken” and the sound will vary. About 50% of the time, the chicken will say “bawk!” and other times it will say “cluck!”.

Chapter 9 Solutions

Java: An Introduction to Problem Solving and Programming (7th Edition)

Additional Engineering Textbook Solutions

Find more solutions based on key concepts
Knowledge Booster
Background pattern image
Computer Science
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
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Java Math Library; Author: Alex Lee;https://www.youtube.com/watch?v=ufegX5o8uc4;License: Standard YouTube License, CC-BY