Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1 Substitution Parent class Child class a instanceof Animal a instanceof Animal

ID: 3900168 • Letter: 1

Question

1 Substitution Parent class Child class a instanceof Animal a instanceof Animal |I b instanceof Zebra a instanceof Animal&& instanceof Zebra a instanceof Animal&& b instanceof Object a instanceof Zebra a instanceof String a instanceof Animal&& b instanceof Zebra a instanceof Animal a instanceof Animal a instanceofTiger For each of the above, could these pair of conditions be: » Preconditions » Postconditions » Neither 2 Class extraction 2.1 Ex 1 A public transport network consists of bus routes, ferry routes and stops. Stops can appear on multiple routes. Passengers travel between stops on busses and ferries (depending on the route type) Timetables describe when busses and ferries arrive at each stop along routes 2.2 Ex 2 A petrol station has a number of pumps each dispensing up to three types of fuel. The car being refueled must be compatible with the nozel for that fuel Customers can pay for fuel either with a credit card transaction at the pump or by walking in to the shop. The shop also sells food, magazines and emergency supplies. High demand items in the shop must be restocked within 12 hours

Explanation / Answer

1.

a. First pair is a valid precondition, as child class just checks if the a != 0 and then parent only takes up a < 0 values

b. Neither, as instance of string cannot be instace of Animal

c. Preconditions: This is also write as child validates the arguments and for parent they will always be true.

d. Postconditions

e. Preconditions

f. Neither, this is never possible

2. Classes and their attrbutes

1. Stops (location, getLocation, setLocation)

2. Route(startpoint, endpoint, arrayOfStops, getRouteInfo, setRoute)

3. BusRoutes (BusNumber, busRoute, getRoute, getStops, setRoute, setBusDetails)

4. FerryRoutes (FerryNumber, ferryRoute, getRoute, getStops, setRoute, setFerryDetails)