go to start Ex W6
|home |print view |recent changes |changed October 25, 2017 |
|You are <- set your identity!

Sections: 0 Catch Up | 1 Date with enum for Month and Weekday | 2 Simulated Switch with toggle button | 3 Finite Field Modulo 5 | Simplification with Boost | Installing Boost (if you are not using the VM) | Optional Exercises | Code Reading Example from {cvu} (Code Critique 106) | Ring Modulo 6 |

0 Catch Up ^

Chances are high that you haven't been able to solve all exercises from last week. So first complete the remaining non-extra exercises from ExW4

1 Date with enum for Month and Weekday ^

The class Date from the lecture examples (chose one you like to start with) is confusing to use, because we specify day, month and year as numbers. Change/implement a Date class that uses an enum type for month consistently, so that one can not specify a wrong date as easily.

Implement a member function day_of_week() for your date class that calculates if a given date is Monday, Tuesday etc. Define a corresponding enum type within the Date class.

Consult wikipedia to figure out how to calculate the day of the week with your calendar. Note, that we only support Gregorian dates.

Maybe another internal representation than 3 numbers for day-month-year, like the number of days since the start of your calendar makes it easier to implement this feature. Even though this might require change to other member functions, but your test cases should help you keep those working. Try also to implement this more compact date representation.

2 Simulated Switch with toggle button ^

To exercise an enum type with hidden values we implement a class Switch. The Switch simulates three states: off, on, blinking. It comes with a single button simulated with the member function pressButton() that switches from off to on to blinking and then to off again. Do not expose the enum values in your Switch.h file.

3 Finite Field Modulo 5 ^

Take the Ring5 class from the github and modify it to a class Field5. We will use it to implement a finite field (galois field/endlicher K├Ârper).

Simplification with Boost ^

Remove all operator implementations you can replace with Boost operators.

Installing Boost (if you are not using the VM) ^

 $ sudo apt-get install libboost-all-dev
 $ brew install boost

Optional Exercises ^

Code Reading Example from {cvu} (Code Critique 106) ^

This is a code reading exercise that contains various C++ features you should be familiar with:

You can ignore that some features of C++ are used that your are not familiar with yet:

The magazine {cvu} has a column about C++ code that does not what it is supposed to do. You should have a look at the submission on page 19 of the September 2017 issue: https://accu.org/var/uploads/journals/CVu29-4_with_cover.pdf

Quick summary: The code is supposed to count different kinds of meals attendees of an event have ordered. Possibilities are any combination of breakfast, lunch and dinner. The programm should print the total number of attendess and the total number of each meal ordered. But somehow the result is not as expected.

To make finding the error easier for you we have created a CUTE executable project with some test cases for the code. It is an archive of a project that can be imported via the menu File->Import...->General->Existing Projects into Workspace. The archive can be found on the Skripte server (only available at HSR internally or VPN): https://skripte.hsr.ch/Informatik/Fachbereich/C++/CPl/Exercises/W06%20CVU%20Code%20Critique/meals.zip

Ring Modulo 6 ^

Implement a class Ring6 that implements modulo arithmetic for unsigned integers modulo 6.

|home |print view |recent changes |changed October 25, 2017 |
|You are <- set your identity!

Ex W6
go to start