-
Notifications
You must be signed in to change notification settings - Fork 0
/
Demo.cpp
32 lines (27 loc) · 1003 Bytes
/
Demo.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/**
* Demo program for message-board exercise.
*
* Author: Erel Segal-Halevi
* Since : 2021-03
*/
#include "Board.hpp"
#include "Direction.hpp"
using ariel::Direction;
#include <iostream>
#include <stdexcept>
using namespace std;
int main() {
ariel::Board board;
board.post(/*row=*/100, /*column=*/200, Direction::Horizontal, "abcd");
cout << board.read(/*row=*/99, /*column=*/201, Direction::Vertical, /*length=*/3) << endl;
// prints "_b_" (starts at row 99 which is empty; then at row 100 there is "b"; then row 101 is empty again).
board.post(/*row=*/99, /*column=*/202, Direction::Vertical, "xyz");
cout << board.read(/*row=*/100, /*column=*/200, Direction::Horizontal, /*length=*/6) << endl;
// prints "abyd__" (First letters are ab; then y from the "xyz"; then d; then two empty cells).
board.show(); // shows the board in a reasonable way. For example:
// 98: _________
// 99: ____x____
// 100: __abyd___
// 101: ____z____
// 102: _________
}