Module [M02] - OOP Thinking
This module supplements the previous one by considering slightly more involved Java classes.
- Textbook Reading Assignments
-
The following sections of the textbook are assigned for this module.
- Chapter #10 – Object-Oriented Thinking
Module Learning Outcomes
In this module, you will develop further your programming skills as follows;
- Tracing
- Ability to read and trace Java programs leveraging classes definitions and objects.
- Implementing
- Ability to write Java programs leveraging classes definitions and objects.
- Testing
- Ability to develop tests for Java programs leveraging classes definitions and objects.
- Debugging
- Ability to troubleshoot Java programs leveraging classes definitions and objects.
- Designing
- Ability to design Java programs leveraging classes definitions and objects.
The following apprenticeship exercises videos will supplement your reading assignments by showing you how to apply the techniques you read about when solving practice exercises from scratch. See remarks in previous module regarding the differences in the software used to write Java programs in the following videos.
- Apprenticeship Exercise - A01 - Course
- File Link: YouTube
- This exercise is used as case study in section #10.5 of the latest edition of our text; it was practice exercise #7.8 in older editions
- Apprenticeship Exercise - A02 - Time
- File Link: YouTube
-
This exercise is # 10.1 in the latest edition of our text; it was #7.7 in older editions.
Write a new class named Time featuring;- Three private int data fields named hour, minute and second with default value SLOW
- A constructor taking a value representing some duration of elapsed Time and using it to populate the above fields
- A constructor without arguments which populates the above fields based on the value returned by System.currentTimeMillist()
- Create a new object with default attributes, then display its description
- Create a new object with specific elapsed time, then display its description
- Apprenticeship Exercise - A03 - MyInteger
- File Link: YouTube
-
This exercise is #10.3 in the latest edition of our textbook;
it was #7.9 in older editions of our text.
Write a new class named MyInteger featuring;- An int data field named value
- An accessor method for this data field
- A constructor which creates a new object which value is specified as parameter
- Methods boolean isEven(), boolean isOdd(), and boolean isPrime() which each return boolean values respectively representing whether the int value in the object is even, odd or prime
- Static methods boolean isEven(int v), boolean isOdd(int v), and boolean isPrime(int v) which operate similarly on their int parameters
- Static methods boolean isEven(MyInteger v), boolean isOdd(MyInteger v), and boolean isPrime(MyInteger v) which operate similarly on their MyInteger parameters
- Methods boolean equals(int) and boolean equals(MyInteger) which determine is our object has the same int value than their parameters
- Method int parseInt(String) which will rely on the Java Integer.parseInt method
- Apprenticeship Exercise - A04 - StackOfIntegers
- File Link: YouTube
- This exercise is used as case study in section #10.6 of the latest edition of our text; It was #7.12 in older editions.
- B01 - MyPoint
- This exercise is #10.4 in the latest edition of our text.
- B02 - Circle2D
- This exercise is #10.11 in the latest edition of our text.
- B03 - MyRectangle2D
- This exercise is #10.13 in latest edition of our text.