o CISC 3115 — Lab #3

CISC 3115
Introduction to Modern Programming Techniques
Lab #03
Classes

How to Develop and Submit your Labs

Overview

The objectives of this lab are: The integer class implemented in this lab are for all practical purposes useless, the primitive int type provides the same operations, and in a much more intuitive fashion. We introduce them for several reasons:

Lab 3.1 Immutable Integer

Lab 3.1.1 An Immutable Integer Class (ImmutableInt) (Approval)

Write an immutable class, Immutable, modelling integers, with the following state/behavior:

stdout

i1: 10
i2: 20
i3: 0

i1.add(i2): 30
i1.sub(i2): -10
i1.mul(i2): 200
i1.div(i2): 0

i1: 10
i2: 20
i3: 0

Lab 3.1.2 An App Class for 3.1.1 (ImmutableIntApp) (Approval)

Write the app class for lab 3.1.1/ The output should match the output as shown in that exercise.

What's the Point of This Lab?

Lab 3.2 Mutable Integer

Lab 3.2.1 A Mutable Integer Class (MutableInt) (Approval)

Write a Mutable class, MutableInt, modelling integers,with the following state/behavior:

stdout

===== Initial Values =====
i0: 0
i1: 10
i2: 5
i3: 20
i4: 25

i0.increaseBy(i1): 10
i0: 10
i1: 10
i2: 5
i3: 20
i4: 25

i0.decreaseBy(i2): 5
i0: 5
i1: 10
i2: 5
i3: 20
i4: 25

i0.multiplyBy(i3): 100
i0: 100
i1: 10
i2: 5
i3: 20
i4: 25

i0.divideBy(i4): 4
i0: 4
i1: 10
i2: 5
i3: 20
i4: 25

i0.reset(): 0
i0: 0

===== Chaining =====

i0.increaseBy(i1).decreaseBy(i2).multiplyBy(i3).divideBy(i4): 4
i0: 4
i1: 10
i2: 5
i3: 20
i4: 25

Lab 3.2.2 An App Class for 3.2.1 (ImmutableIntApp) (Approval)

Write the app class for lab 3.1.1/ The output should match the output as shown in that exercise.

What's the Point of This Lab?