首页
网站开发
桌面应用
管理软件
微信开发
App开发
嵌入式软件
工具软件
数据采集与分析
其他
首页
>
> 详细
讲解COSI 12B编程课程、辅导program程序、Java,Python语言编程辅导 辅导留学生
项目预算:
开发周期:
发布时间:
要求地区:
COSI 12B – Advanced Programming Techniques
Programming Assignment 4
Objective
Practice developing a well encapsulated object-oriented program
Practice using Eclipse Debugger Tool
Overview
In this assignment, you will be simulating a building that contains a single
elevator. However, this elevator has a special characteristic, it can only be used
once by a person as they enter the building. Once someone has used the elevator
they will remain at their floor forever. You can think of this elevator as a one-
way elevator.
Person instances will request to enter the building and go to a specific floor.
Two things need to happen. As a person arrives at the building, the elevator may
or may not be on the first floor, ready to take new passengers. To address this
problem, we will put a “job” on the elevator to go to floor number 1, and
immediately after put a second “job” for the person that has entered the building
to go the their desired floor. More is said about this further on.
This elevator will not be very efficient, since it will process “jobs” in order
(first-come-first- serve). So, if two people come to the building, the elevator will
come to the first floor, take the first person and then take them to their desired
floor, and then go back to the first floor for the second person that entered the
building. The elevator is given a batch of “jobs” and then it should process the
entire batch as fast as possible.
You will be coding an Object-Oriented solution, where you will need to
implement the following classes:
Building: It should hold an array of floors and an instance of an elevator.
Floor: Every floor must contain an array of people (that are currently on a given
floor). ?
Elevator: An elevator will contain a list of Jobs (as an array), where each Job
represents a person and the floor to which they desire to go. The elevator should
also contain a?reference to the building to which it belongs. ?
Person: Each person has a first name and a last name.
Job: This class is used to represent an elevator trip. This class holds a reference
to a Person and a floor number. You can use a null object for the first parameter
to represent an empty trip (calling the elevator to the first floor). ?
Simulation: This class should contain a main method, where you simulate the
building. You should instantiate a building, and several person instances. Then
you should simulate two different groups of people, arriving at different times,
and requesting to use the elevator. Print the state of the
building/elevator/people’s locations in order to show what is going on in the
building as the elevator runs. This is so the user can tell what is going on.
Implementation Details
The idea is that a client program should be able to create person instances and a
building instance. Then, each person could call a method to enter the building,
where the building instance is passed as a parameter. Then a method would be
called from the building instance on its elevator, creating a “job” or trip to be
executed. The details of each class and the necessary methods are below. Note
that you may use additional methods in your classes in order to have an
organized and modular solution. Analyze the code and decide how to implement
your solution. We are not looking for a uniquely right solution, so use your own
judgement as a programmer and describe your logic in a README.txt file.
Note: Feel free to pass as many parameters in each constructor method as you
see fit. Comment your code very well, as we will be evaluating your logic and
your understanding of object- oriented practices.
Building Class
public boolean enterElevator(Person person, int
floor) — This method will process the request made by a person to enter
the building. Then, it should pass on the request to an elevator instance.
Make sure that the elevator visits the first floor and then the floor requested
by the person.
person: the person that has requested access to the building
floor: the number of the desired floor
public void startElevator() — This will call a method in the
elevator instance that should process all current jobs.
public boolean enterFloor(Person person, int floor)
— This method should simply access the given floor object and call a
method to save a reference to the person in the given floor.
person: the person to access the floor
floor: the floor number to be entered ? ?
Person Class
public boolean enterBuilding(Building building, int
floor) — This method will simply call the appropriate method from the
building instance to enter the elevator and request a job.
building: the building to be entered
floor: the floor requested
public String getLocation() — You should hold a variable (that
you will need to update at certain moments) that will say the location of a
person. You can choose how to implement this, but you should return strings
like "In lobby”, "In Elevator", or "In floor 4", etc... ?
Floor Class
public boolean enterFloor(Person person) — This method
should save a reference to the person within the floor object
person: the person to enter the floor
Job Class
public Job(Person person, int floor) — This class is used
mostly to hold information.
person: the person that requested a job (or null if the elevator was
requested to go to the lobby to pick up a person)
floor: the floor number that has been requested
Elevator Class
public public boolean createJob(Person person, int
floor) — This method should simply add, in the right place, a new job to
be completed by the elevator.
person: the person that requested the elevator
floor: the desired floor number
public void cleanUpJobs() — This method will be used after
completing (and removing) a job. The use of this method should guarantee
that the jobs array is in a valid state.
public void processAllJobs() — This method should remove
jobs one by one (in the right order) and process them individually.
public boolean processJob(Job job) — This method should
process a job, and move the elevator floor by floor (while printing updates)
in order to reach the desired floor. Then, the exit method should be called,
simulating the exit of a person (if necessary).
job: the job to be processed
public boolean exit(Person person, int floor) — This
method should call a method on the building for a person to enter a given
floor (hold a reference to the person in the given floor).
person: the person exiting at a given floor
floor: the floor at which the person is exiting ?
Please make sure to read and understand the code provided before
attempting a solution. There are additional comments that are very
important to your task. If you draw a simple diagram of how the classes
interact and what the flow of the program will be before you start coding, it will
be much, much easier to complete this assignment.
Debugging
Use the debugger included with Eclipse to debug your program step by step:
1. Set a breakpoint in the code just before where you are experiencing a
problem. If you set the breakpoint on the 1st statement of your main
method, you will be able to step through every line of code in your
program.
a. Right click on the number of the line of code where you would like
to set the breakpoint
b. Select Toggle Breakpoint to set or remove
c. You will see a little blue dot appear to the left of the line number
when the breakpoint is set.
2. Run the program in Debug Mode
a. Click on the “Debugger” button
b. First time you run this, you will be prompted to switch perspectives.
Agree to that. Eclipse will open additional windows useful for the
debugging process
3. Set through your code to watch where each step takes. (1) You can jump
into the functions (all the way to the Java source code). (2) You can jump
over statements to execute them without going into them. (3) You jump
out of functions to get back to the calling function. (4) You can stop
execution to start again.
软件开发、广告设计客服
QQ:99515681
邮箱:99515681@qq.com
工作时间:8:00-23:00
微信:codinghelp
热点项目
更多
代做ceng0013 design of a pro...
2024-11-13
代做mech4880 refrigeration a...
2024-11-13
代做mcd1350: media studies a...
2024-11-13
代写fint b338f (autumn 2024)...
2024-11-13
代做engd3000 design of tunab...
2024-11-13
代做n1611 financial economet...
2024-11-13
代做econ 2331: economic and ...
2024-11-13
代做cs770/870 assignment 8代...
2024-11-13
代写amath 481/581 autumn qua...
2024-11-13
代做ccc8013 the process of s...
2024-11-13
代写csit040 – modern comput...
2024-11-13
代写econ 2070: introduc2on t...
2024-11-13
代写cct260, project 2 person...
2024-11-13
热点标签
mktg2509
csci 2600
38170
lng302
csse3010
phas3226
77938
arch1162
engn4536/engn6536
acx5903
comp151101
phl245
cse12
comp9312
stat3016/6016
phas0038
comp2140
6qqmb312
xjco3011
rest0005
ematm0051
5qqmn219
lubs5062m
eee8155
cege0100
eap033
artd1109
mat246
etc3430
ecmm462
mis102
inft6800
ddes9903
comp6521
comp9517
comp3331/9331
comp4337
comp6008
comp9414
bu.231.790.81
man00150m
csb352h
math1041
eengm4100
isys1002
08
6057cem
mktg3504
mthm036
mtrx1701
mth3241
eeee3086
cmp-7038b
cmp-7000a
ints4010
econ2151
infs5710
fins5516
fin3309
fins5510
gsoe9340
math2007
math2036
soee5010
mark3088
infs3605
elec9714
comp2271
ma214
comp2211
infs3604
600426
sit254
acct3091
bbt405
msin0116
com107/com113
mark5826
sit120
comp9021
eco2101
eeen40700
cs253
ece3114
ecmm447
chns3000
math377
itd102
comp9444
comp(2041|9044)
econ0060
econ7230
mgt001371
ecs-323
cs6250
mgdi60012
mdia2012
comm221001
comm5000
ma1008
engl642
econ241
com333
math367
mis201
nbs-7041x
meek16104
econ2003
comm1190
mbas902
comp-1027
dpst1091
comp7315
eppd1033
m06
ee3025
msci231
bb113/bbs1063
fc709
comp3425
comp9417
econ42915
cb9101
math1102e
chme0017
fc307
mkt60104
5522usst
litr1-uc6201.200
ee1102
cosc2803
math39512
omp9727
int2067/int5051
bsb151
mgt253
fc021
babs2202
mis2002s
phya21
18-213
cege0012
mdia1002
math38032
mech5125
07
cisc102
mgx3110
cs240
11175
fin3020s
eco3420
ictten622
comp9727
cpt111
de114102d
mgm320h5s
bafi1019
math21112
efim20036
mn-3503
fins5568
110.807
bcpm000028
info6030
bma0092
bcpm0054
math20212
ce335
cs365
cenv6141
ftec5580
math2010
ec3450
comm1170
ecmt1010
csci-ua.0480-003
econ12-200
ib3960
ectb60h3f
cs247—assignment
tk3163
ics3u
ib3j80
comp20008
comp9334
eppd1063
acct2343
cct109
isys1055/3412
math350-real
math2014
eec180
stat141b
econ2101
msinm014/msing014/msing014b
fit2004
comp643
bu1002
cm2030
联系我们
- QQ: 9951568
© 2021
www.rj363.com
软件定制开发网!