go to start Ex W6
|home |print view |recent changes |changed November 22, 2016 |
exact
|You are 54.81.59.211 <- set your identity!

Sections: Remember to finalize your "Testat" Exercise | 0.1 Catch Up | 1 A value class for Words (This will be required for next Testat!) | 1.1 =[Word]= value class | 1.2 =[wlist]= revisited using =[Word]= | 2 Date with enum for Month and Weekday | 3 Simulated Switch with toggle button | Installing Boost (if you are not using the VM) |

Remember to finalize your "Testat" Exercise ^

if you haven't done so by now!

0.1 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 A value class for Words (This will be required for next Testat!) ^

1.1 Word value class ^

Create a class Word that represents a single word. It can be input with >> and output with <<. When input, a word will only consist of letters (std::isalpha(c)) and ignore all white-space, digit or punctuation characters. All the latter terminate a word. Thus, an std::istream containing the sequence "compl33tely ~ weird !!??!! 4matted in_put" would result in six Words ("compl", "tely", "weird", "matted", "in", "put"). Each call of the input operator reads one word.

Write CUTE unit tests for all behavior your word class shows!

Write a test that checks what happens at the end of the input with the input stream. Will an empty word be created, even if it is forbidden?

1.2 wlist revisited using Word ^

Based on this class Word, implement the exercise wlist from last week ExW4 with this class. Does the program become simpler with your library class instead of using std::string (it should)?

2 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.

3 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.

Optional: If you have implemented the ANSI Terminal from ExW4 you can use it implement a visualization. To put the output of the Switch's effects on the screen of a terminal, place a cursor top-left and output the status in white on black for off, black on white for on and blinking for blinking using the corresponding ANSI escape sequences.

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

As we are going to use Boost in the upcoming exercises, it is now time to install it if you do not have it.

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


|home |print view |recent changes |changed November 22, 2016 |
exact
|You are 54.81.59.211 <- set your identity!

Ex W6
go to start