Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

code needs to be written in java Partner Lab 1: Overcrowded Elevators Submit Assignment Due Friday by 11:59pm Points 100 Submitting a file upload File

image text in transcribedimage text in transcribedimage text in transcribedcode needs to be written in java

Partner Lab 1: Overcrowded Elevators Submit Assignment Due Friday by 11:59pm Points 100 Submitting a file upload File Types java and zip Available until Feb 21 at 11:59pm Important: Although this is a Partner assignment, each student must submit their own assignment -- not doing this will result in a grade of zero. Working with a partner is optional. If you do choose to work with a partner, please specify their name when submitting your assignment. Description: In this assignment, we will learn about Object Oriented Programming by creating an application that uses Java classes to simulate multiple people and the multiple elevators that they may enter -- as long as they don't push the total weight of the elevator over its limits. Requirements: You should follow all proper coding conventions and practices as discussed in class. Use descriptive and correct variable and method names. Indent properly. You should not use global variables or static methods (other than your main method) anywhere in this assignment. Your Elevator class should store an ArrayList of Person objects as a class attribute (as shown in class). Make sure your code compiles and runs without errors. Step 1: Create a new Java class named PartnerLab1. Add your main method to this class. Create a new Java class named "Elevator" Create a new Java class named "Person" Each of these classes should be created in its own (appropriately named) file. These three files should be uploaded to Canvas once complete. Step 2: Implement a properly encapsulated "Elevator" class that uses an object-oriented approach to store the following information: Weight limit Total current weight of all occupants All information about any people in that elevator (Note: all weights in this assignment can be represented as whole numbers) ...and methods to perform the following tasks: Set the weight limit Set the total current weight Return all info about the elevator and its occupants (you may want to call this method getInfo()) Add a person to the elevator by: 1. Testing if their weight would cause the elevator to exceed its weight limit if they entered. 2. Returning true and updating the total current weight in the elevator to reflect the addition of their weight (if they are able to enter). 3. Returning false if they are unable to enter. Step 3: Create a no argument constructor for the Elevator class that sets both the weight limit and the total weight to a default value of 0. Step 4: Implement a properly encapsulated "Person" class that has the following attributes: Name Weight in pounds ...and methods to perform the following tasks: . Get the name . Get the weight Return all info about the person (you may want to call this method getInfo()) Step 5: Create a two argument constructor for the Person class that takes in the name and weight and sets both attributes accordingly Step 6: In your main method: Create two instances of your Elevator class. Use your setter to set the weight limit of each elevator. There is no need to modify the total weight at this point since nobody is in the elevator to start. Repeatedly prompt the user to add a person (including name and weight), or type "q" when done with that elevator. Attempt to add each person to the elevator. . If the attempt is successful, display "Person added" along with the name and weight of that person. o If the attempt is unsuccessful, display "Person could not be added." Note that people will initially be added to the first elevator until the user types 'q', which will cause subsequent people to be added to the second elevator. Typing 'q' a second time will indicate that the user is done adding people to the second elevator. Finally, display all of the info for both elevators and each of the people inside it by calling the getInfo() method of each elevator. Each field should be labelled. BONUS (for up to 5 extra points) Create an addPeople method in your Elevator class that takes in an array of Person objects as a parameter Add logic in the addPeople method to determine which people should enter the elevator to allow the maximum number of people without going over the weight limit Return an array of people who can enter based on the previous step

Step by Step Solution

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_2

Step: 3

blur-text-image_3

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

Databases In Networked Information Systems 6th International Workshop Dnis 2010 Aizu Wakamatsu Japan March 2010 Proceedings Lncs 5999

Authors: Shinji Kikuchi ,Shelly Sachdeva ,Subhash Bhalla

2010th Edition

3642120377, 978-3642120374

More Books

Students also viewed these Databases questions

Question

determine themaximum deduction available to penni for car expenses

Answered: 1 week ago