Exercise 2 - Subtype and Supertype

1 Question

What is a type?


1.1

A type can conceptually be viewed as a set of values. If x has the type Real, this means that x belongs to the set of values represented by the type Real.


2 Question

What is a subtype?


2.1

The subtype relation between types is analogous to the subset relation between sets. If a type A1 is a subtype of A, the set of values corresponding to type A1 is a subset of the set of values corresponding to type A.


3 Question

What is a supertype?


3.1

The supertype relation is the inverse of the subtype relation.


4 Subtype and Supertype




Define a class
Room that is a Subtype of the class House. Which also means that House is a Supertype of Room. Also give the variables some values.



4.1


4.1.1 Simulation of Room