CS3342 Tutorial w02 03 OOExamplesAndExercises
CS3342 Tutorial w02 03 OOExamplesAndExercises
In Library System Ver. 3.0, we need to support child, adult and senior library
members, with different late book return penalty fine rate (i.e. $3/day for
children, $10/day for adult, $5/day for seniors). We also know that a child will
becoming an adult in one day and an adult will become a senior in one day.
Explain why Design B is better than Design A?
Task 3: Open BlueJ and create two separate projects (Design_A and Design_B),
and important (drag_and_drop) the generated code into the BlueJ system. Add
“import java.util.Date;” to the first line of class Borrowing.
1
CS3342- TUTORIAL No.2 , v.3
Task 4: Analyze the differences between the two designs. Attempt to answer
why Design B is better than Design A?
Task 4 Answer:
Note that if the conceptual constraint does not exist, i.e., there is no
requirement to model the change of states of a member, Design A is better
than Design B because Design B has over-engineered the solution.
Analyze the following code that models the program using the OO approach.
Procedural approach
#include <iostream>
#include <string>
using namespace std;
void main() {
// 1. Get input.
int n;
cin >> n;
2
CS3342- TUTORIAL No.2 , v.3
3
CS3342- TUTORIAL No.2 , v.3
Task 1 - Design: VP: Below is a Simple Class diagram (BlueJ) Please attempt to
use Visual Paradigm to generate a more complete Class Diagram.
4
CS3342- TUTORIAL No.2 , v.3
5
CS3342- TUTORIAL No.2 , v.3