Beruflich Dokumente
Kultur Dokumente
Lab Assignment 3
In this lab assignment you will implement 2 classes. You use:
creation of objects
internal and external method calls
selection using if statements
object reference this
This lab has the same learning content of lab assignment 2. So if you did not yet do
lab assignment 2, proceed with this (including lab assignment 2b) and keep this lab
for personal training at home.
CS 212
Page 1 of 4
type
String
String
String
House
House
methods:
name
rentHouse
return
type
void
paramete
rs
House h
buyHouse
void
House h
printHouse
void
none
printRentedHo
use
void
none
CS 212
description
the person rents the specific house; to do
so the setter method for tenant in the
house is called and the person itself is
passed as tenant
the person buys the specific house; to do
so the setter method for owner in the
house is called and the person itself is
passed as owner.
all information of the owned house is
printed (including the tenant name, if the
house is rent). If the Person does not own
a house the message you dont own a
house is printed. If the house is not
rented, the message The house is not
rented is printed.
all information of the rented house is
printed including the name of the owner
(if exist). If the person does not rent a
house, the message you do not rent a
house is printed. If the house has no
owner, the message the house has no
owner is printed.
Page 2 of 4
type
int
int
float
Person
Person
methods:
The constructor receives the id, roomNb and rent as parameters. All other
values are set to null.
getter methods for id, roomNb, rent, owner, tenant
setter methods for rent, owner, tenant
other methods:
name
return
type
void
parameter
s
none
void
none
printTenantInform
ation
void
none
printAllInformatio
n
void
void
printHouseInform
ation
printOwnerInform
ation
CS 212
description
prints the id, the number of
rooms and the rent of this house
prints name, phoneNb and
address of the owner
if there is no owner the message
there is no owner is printed
prints name and phoneNb of the
tenant
if there is no tenant the message
the house is not rent is printed
prints all information related to
the house by calling the other
methods of this class
Page 3 of 4
CS 212
Page 4 of 4