HTW Berlin
Fachbereich 4
Internationaler Studiengang
Internationale Medieninformatik (Bachelor)
Info 2: Informatik II
Winter Term 2010/11
Exercise 8: Fun with Calculators - Week 3
Finger exercises
We are then going to make a calculator for a different data type that just ints. Of course, the bored are welcome to implement any fascinating new data types they can think up for using a calculator with!
Choose one of the following data types:
Either polish your extended JulianDate class or see if one of the bored has made something useful. Make sure that you can read and write dates in a specific format. Add methods such as public void addDays (int days); if necessary. Decide how you are going to map functions such as adding or subtracting a number of days to a date, determining the number of days between a date, and determining the weekday to the buttons +, -, *, and /.
You can either implement your own set, or use the Java Set data type to implement your set calculator. How are you going to do the input? Start with just sets of single digits. {1, 3} + {1, 4} = {1, 3, 4}. How are you going to map the functions such as adding, subtraction, or intersecting sets to the buttons on the calcualtor?
How do you get the calculator to accept input of your chosen data type and to display output of the chosen type?
Lab exercises
Make another new copy of the Calculator (don't wreck your previous versions) before you start.
If you are doing the date calculator, implement the following functions:
input a date
get the calculator to display a String for the weekday in the window (hint: you will need a button to push)
add a number of days to a date, displaying the new date
subtract a number of days from a date, displaying the new date
subtract two dates, giving the number of days between the dates
If you are doing the set calculator, implement the following funcitons:
input a set
get the calculator to display the number of elements in the set (hint: you will need a button to push)
add two sets, displaying the result set (this function is commonly called the union)
subtract one set from another
calculate the intersection of two sets
The bored can make a power set function.
For the bored:
Have variations for the date display format: German, American, ISO
Add buttons to your fancy calculator for switching locale for the dates. Now include a button that, when pressed, speaks the number or word currently on the display of your calculator. Blinking lights are not necessary, but maybe you can make it skinable. It does look like
it is going to rain this weekend though ....
Work in groups of two, each of you submits the same report, detailing who did what
part of the work. Your reports are due by 23.00 next week.