Hi math01-ga,
As you probably know, Java is an object oriented programming language,
and so it allows for problems to be solved through the use of object
classes where instances of objects can be created and manipulated.
The following definitions should help you understand basic object
oriented modeling:
Object - a representation of a real-life entity
State variables - the characteristics associated with an object
Object messages - commands (also known as methods) that are used to
manipulate an object and its characteristics
Now on to the problems...each problem lists objects in all capitals
followed by state variables and methods. Assume that all object state
variables include appropriate constructors, accessors and mutators.
For example, if we had a Dog object that included an age state
variable:
Dog() // creates a new default Dog
getAge() // returns age of Dog
setAge(int years) // changes age of Dog to years
Problem 1. Management of airports
AIRPORT
name
location
runways
gates
addGate()
addRunway()
removeGate()
removeRunway()
changeName()
PLANE
planeID
homeAirport
seats
fuelTankSize
fuelRemaining
staffRequired
pilotsRequired
age
fillFuelTank()
incrementAge()
STAFF
staffID
name
address
phoneNo
yearsEmployed
salary
preferredLocations[]
qualifiedDuties[]
addLocation(Airport a)
removeLocation(Airport a)
incrementYears()
giveRaise(int raise)
addDuty(Task t)
removeDuty(Task t)
TASK
taskID
name
payRate
increaseRate()
rename()
PASSENGER
passengerID
name
address
phoneNo
airMiles
flightsBooked
addAirMiles(int distance)
bookFlight()
cancelFlightBooking()
FLIGHT
flightID
departsFrom
arrivesAt
passengersCarried
staffAssigned
pilotsAssigned
estimatedTime
addPassenger(Passenger p)
assignStaff(Staff s)
assignPilot(Staff s)
Problem 2. Operations of a hospital
PATIENT
patientID
name
address
phone
deadOrAlive
nextOfKin
insuranceData[]
symptoms[]
addSymptoms()
kill()
BED
bedID
inUse
width
length
location
boolean isOccupied()
fill(Patient p)
vacate()
STAFF
staffID
name
address
phoneNo
yearsEmployed
salary
preferredShifts[]
qualifiedDuties[]
addShift(int time)
giveRaise(int raise)
incrementYears()
addQualified(int task)
DOCTOR extends STAFF
specialties[]
pagerNo
seniorityLevel
assignedNurses[]
surgeriesBooked[]
bookSurgery(int time)
addNurse(Nurse n)
removeNurse(Nurse n)
addSpecialty(int specialty)
NURSE extends STAFF
assignedDept
assignedDoctors[]
addDoctor(Doctor d)
removeDoctor(Doctor d)
Problem 3. Administration of a course, like the one you are currently
taking
INSTRUCTOR
instID
name
address
phoneNo
subjects[]
yearsTeaching
salary
addSubject(int subject)
giveRaise(int raise)
incrementYears()
STUDENT
studentID
name
address
phoneNo
coursesTaken[]
coursesRegistered[]
GPA
yearsCompleted
registerInCourse(Course c)
dropCourse(Course c)
incrementYears()
COURSE
subjects[]
level
studentCapacity
students[]
instructors[]
seniorityRequired
salaryLimit
addStudent(Student s)
removeStudent(Student s)
assignInstructor(Instructor i)
Problem 4. Window-based operating system
PROCESS
pID
owner
permissions[]
alive
active
startProcess()
resumeProcess()
pauseProcess()
killProcess()
USER
dateCreated
dateModified
userID
name
permissions[]
settings[]
active
logIn()
changeSetting(int index, int newSetting)
FILE
fileID
fileName
path
data[]
associatedProgram
lastOpened
lastModified
dateCreated
read()
write()
print()
move()
copy()
delete()
Problem 5. A paint program, like MSPaint or PaintShop Pro
Once you have identified the objects for a problem, determine the
object's state and the types of messages to which it responds.
CANVAS
location
color
length
width
resize(int length, int width)
changeColor(int color)
POINT
xCoord
yCoord
color
OVAL extends POINT
xRadius
yRadiue
RECTANGLE extends POINT
width
length
I hope that helps you understand object oriented design a little
better. Please keep in mind that the models listed above are meant to
act as examples of solutions to the problems given. The ultimate goal
of OOD is to design objects that are able to emulate the properties
and functions of a real problem, which can only be done when one is
presented with a real-life problem.
If you have any problems understanding the information above please
feel free to post a clarification and I will respond promptly :)
Cheers!
answerguru-ga |