|
|
HTW Berlin
Fachbereich 4
Internationaler Bachelor Studiengang
Internationale Medieninformatik (Bachelor)
Info 2: Informatik II
Summer Term 2018
|
Exercise 5: Fun with Calculators 1 |
Finger Exercises
Please have these completed before coming to the
lab.
- You all know what a calculator is! Here's some code: calculator-full-solution. Have a look at how it solves the problem of reading in a digit
followed by an operator followed by a digit, and how
to calculate the value when = is pressed.
- Is there anything important missing in this calculator? Beware:
do not expect to read and understand this in the first few minutes of the
lab! Read it at home, discuss it with others, perhaps over the class forum so that we can join in and help! How does it work?
- What are hexadecimal numbers, by the way?
Lab exercise:
These are the required exercises for this week. Work in groups of two, doing pair programming, and turn in the same report for each member of the pair.
- Implement the missing functionality for single digit numbers and only one operator discovered in the pre-lab.
- Extend your integer calculator without making any changes to your superclasses except for changing privates to protected to include buttons for entering
in the hexadecimal digits. Make the calculator do its calculations and display
in hexadecimal notation.
- Integrate a checkbox for switching between decimal
and hexadecimal formats. Do not show the hexadecimal digits (or grey them out) when you have the calculator in decimal mode.
- What test cases do you need to test your calculator? If you find errors in your calculator, document them in your report!
For the bored:
- Make a whole collection of calculators: binary,
octal, decimal, hexadecimal. Maybe make a CalculatorFactory that takes
the base as a parameter to the constructor, figures out how to layout the
buttons nicely, and calculates in the selected base mode?
Your report is due by 10.00 pm the evening before your next lab! As in Informatics 1, we aremore interested in process than in product, although we are now getting more interested in products as well. Your report should include any collaborators, summarize what you learned, and note the time you invested in this exercise. How many lines of code did you write for each exercise? Record this in your report.
Copyright
Prof. Dr. Debora Weber-Wulff
Questions or comments:
<weberwu@htw-berlin.de>
Some rights reserved. CC-BY-NC-SA - Copyright and Warranty