Classes
Zabi
Zabis are a friendly furry creature from Australia. Zabis wear a very big watch and a hat it likes to turn around sometimes. Zabis also carry a smaller creature called spitz which can bite threatening predators.
- Implement a
Watch
class with ashow
method - Implement a
Hat
class with the following methods:turn
- Turns the hat backwards and forwards alternatingly.tip
- Print 'Hat tip'.
- Implement the
Spitz
class with following methods:bite
hide
- Note that the spitz should not be able to turn Zabis' hat.
- Implement
Zabi
with following methods:attack
- Send the spitz on a biting attack.defend
- Tell the spitz to hide.direction
- Shows the current direction of the hat.time
- Show the watch.
Turing Machine
Note This is not intended to be a true turing machine. Rather a simplified version. A turing macine is a computational model which can do any computation a modern computer can do. A turing machine consists of an input tape with a read-only head and an output tape with a read/write head.
Implement a turing machine which decides the following language: For any given sequence of 0's and 1's, accept if the amount of 0's is equal to the amount of 1's. Otherwise reject.
Note Use std::vector
.
- Implement the
Input
class with following methods:read
- Read the current cell from the input tape. This method should not change any fields.left
- Move the head left one cell.right
- Move the head right one cell.
- Implement the
Output
class with following methods:write
- Write a 1 to the output tape.erase
- Erase the last 1 from the output tape.isEmpty
- Return true if the output tape is empty.
- Implement the
TM
class with the following methods:- Constructor:
- Receive an input and load it onto the internal input tape.
- Set the machine
state
field to 'start'.
run
- Run the machine and set the state accordingly to accept or reject. When done show the machine state.setState
- Change the machine state.
- Constructor: