Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java Problem Statement: A company intends to build a two-story office building and equip it with the latest elevator technology. The company wants you to

Java

Problem Statement:

A company intends to build a two-story office building and equip it with the latest elevator technology. The company wants you to develop a Java program that simulates the operation of the elevator to determine if it will meet their needs.

The elevator, which has a capacity of one person, is designed to conserve energy, so it only moves when necessary. The elevator starts the day waiting with its doors closed on the building's first floor. The elevator, of course, alternates directions—first up, then down.

Your simulator has a simple graphical user interface—using JavaFX with a single New Person push button. When the button is clicked, the simulator creates a “new” Person and places that person on a floor (i.e., floor one or floor two). The arrival floor of the person is randomly determined. The person then presses the floor’s call button. The person’s destination floor is never equal to the floor on which that person is created.

If the first person of the day arrives on floor one, the person can immediately get on the elevator (after pressing the call button, and waiting for the floor doors and the elevator doors to open, of course!). If the first person arrives at floor 2, the elevator should proceed to floor 2 and “pick up” the person. For simplicity, in this version of the simulation, the elevator moves between the floors in zero time. This will be made more realistic in future versions of your elevator application.

The elevator's arrival at a floor is signaled by turning on a light on that floor above the doors and by ringing the floor bell. The floor button and the elevator button are reset, the elevator's doors open, the floor's doors open, and the passenger gets out of the elevator. If a passenger is waiting on that floor the passenger boards the elevator and presses a destination button. If the elevator need to begin moving, it determines in which direction it should go (a simple decision on a two-story elevator!), and begins moving to the other floor. For simplicity assume that all the event that happen once the elevator reaches a floor and until the floor’s doors are closed, take zero time. The elevator always knows its current floor and its destination floor.

Due to the fact that all events in this version of the simulation take zero time, only one person can be in the simulation at a time. The simulator should process each person completely before the next person arrives in
the simulation. In other words, when a person is created, that person should press the call button, be picked up by the elevator, be moved to the opposite floor and should exit the elevator before the next person walks onto a floor to wait for the elevator.

Classes: Floor, Elevator, Person, Building, New Person Button, call button, Floor Door, Elevator Door, floor light, and floor bell.

1. Extract all the facts from the problem above. Eliminate all irrelevant text and place each fact on a separate line of your text file (there are several dozen facts in the problem statement.) Here is a portion of what your fact file might look like:· two-story office building · elevator · person · floor doors · elevator doors · directions-up and down · floor is occupied · person in elevator · person on floor · person's destination floor · person gets on elevator o elevator closes its doors.

2.Group all your facts by class. Use an outline form in which the classes are listed at the left margin of the page and the facts related to each class are listed below that class and indented one tab. Some facts mention only one class while other facts mention several classes. Each fact should initially be listed under every class the fact mentions. Note that some facts like "directions-up and down” do not explicitly mention a class but should nevertheless be grouped with a class (in this case the direction is clearly the direction in which the elevator is moving).


3. Now separate the facts for each class into two groups. Label the first group Attributes and the second group Other Facts. For now, actions (behaviors) should be grouped under Other Facts. As you place an action under Other Facts consider creating an additional entry under Attributes if appropriate. For example, the fact
"elevator closes its doors" is an action that for now is grouped under Other Facts, but it indicates that an attribute of "doors" is that they are either open or shut. The fact "floor is occupied" is an attribute of the floor, more specifically, floor is either occupied (by one person—the stated capacity of each floor) or unoccupied at any time. Some attributes of the elevator are: whether it is "moving" or "stopped,' whether it does or does not have a passenger, and if it is moving—whether it is moving "up" or "down." An attribute of the floor button is whether it is "on" or "off." An attribute of a person is the person's destination floor. And so on.

Step by Step Solution

3.48 Rating (161 Votes )

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Valuation Measuring and managing the values of companies

Authors: Mckinsey, Tim Koller, Marc Goedhart, David Wessel

5th edition

978-0470424650, 9780470889930, 470424656, 470889934, 978-047042470

More Books

Students also viewed these Mathematics questions