-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTape.h
More file actions
40 lines (30 loc) · 813 Bytes
/
Tape.h
File metadata and controls
40 lines (30 loc) · 813 Bytes
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
32
33
34
35
36
37
38
39
40
#pragma once
#include <string>
using std::string;
class Tape {
public:
Tape(char blank = ' ') : blank_symbol(blank), head(new TapeCell(nullptr, nullptr, blank)) {};
Tape(const Tape& other);
Tape(string, char = ' ');
Tape& operator= (const Tape& other);
~Tape();
void goLeft();
void goRight();
void replaceSymbol(char new_symbol);
char getSymbol() const;
char getBlank() const { return blank_symbol; }
void insertStringToTape(const string& str);
operator string() const;
private:
struct TapeCell {
char symbol;
TapeCell* left;
TapeCell* right;
TapeCell(TapeCell* left, TapeCell* right, char symbol) : left(left), right(right), symbol(symbol) {};
};
TapeCell* head;
TapeCell* copyOther(const Tape&);
TapeCell* getFirst() const;
void deleteContent();
char blank_symbol = ' ';
};