You are on page 1of 16

EXERCISES

IF Ubaya (Infor+SI+MM+ITDD)

1
Review: What have you learnt?
 We have learnt many concepts of OOP
 We have add checking in properties
 We have add throw exception in properties
 We add try-catch exception in our application

2
What will you learn today?
 You will strengthen your skill in creating class,
error handling (exception handling), and using
class in an application

3
EXERCISE 1: TIME
APPLICATION

4
Exercise 1: Time Application
 Requirements:
 A time object composed of hour, minute, and second.
Example : 10:30:44, 12:59:50, etc..
 A time can be converted to seconds and can be added
with seconds.
 Create the class (you can draw class diagram first or
create new class directly).
 Naming convention :
Project/solution : yournameTimeApps (ex:
ellysaTimeApps, mayaTimeApps, etc..)
Class : yournameTime (ex: ellysaTime, jokoTime, etc..)
 Add appropriate data members, properties, and
methods
 Use your class in application. 5
Exercise : Time Application

 Add checking in properties


 Hour: 0-23
 Minute: 0-59
 Second: 0-59
 Add throw exception in properties
 Add try catch exception

6
This is the application that we will create
 Create new windows
application project
 Copy the interface inside the
form of Playing with Time
application project which
already provided for you
 Paste the interface to your
new form

7
Catch exception

8
Catch exception

9
EXERCISE 2: Fractional
Number Calculator

10
Exercise 2: Fractional Number Calculator

 Program requirements:
 Your calculator should be able to perform the
multiplication, addition, subtraction, and division
of two fractional numbers
 The result must be shown in the simplest form of a
fractional number

11
Exercise 2: Fractional Number Calculator

Only display the numerator and


denumerator of fract1 and fract2.
We will discuss how to calculate the
operation result in the next meeting

12
NAMING
Class Project (namespace):
yourNameFractionalCalc

Class: yourNameFractNumber

13
Fractional Number Calculator

 Add checking in properties


 Denominator (Penyebut) : cannot be 0
 Add throw exception in properties
 Add try catch exception

14
Fractional Number Calculator

15
Marking Guideline
• 100 : Class and program using the class works correctly
• 75 : Class works correctly, but the program using the class
do not work correctly
• 50 : The program using the class works correctly, but the
class was not built correctly (minor mistakes)
• 25 : The program using the class works correctly, and the
class was not built correctly (major mistakes)
• 0 : No submission or upload empty project

16

You might also like