-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMorseSystem.h
More file actions
70 lines (53 loc) · 2.35 KB
/
MorseSystem.h
File metadata and controls
70 lines (53 loc) · 2.35 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// Alfred Ledgin
// 12/4/2015
// CS 303
// Project 3
#pragma once
#include "MorseCode.h"
#include <iostream>
#include <string>
using namespace std;
class MorseSystem
// This class serves as an external means of using the MorseCode class.
// It provides access to the three main functional components of the
// MorseCode class: defining a code set, decoding a Morse Code word,
// and encoding a word in Morse Code.
{
public:
MorseSystem() {;}
// Preconditions: A MorseSystem object needs to be created.
// Postconditions: This default constructor simply creates a
// MorseSystem object and the MorseCode object contained within
// it.
MorseSystem(istream& input) {setInput(input);}
// Preconditions: A MorseSystem object needs to be created with the
// given source for the Morse Code alphabet definition.
// Postconditions: This constructor creates a MorseSystem object using
// the given input in order to define the Morse Code alphabet.
void setInput(istream& input) {definitionSet.buildCode(input);}
// Preconditions: A MorseSystem needs its Morse Code alphabet defined
// according to the given input definitions.
// Postconditions: This function calls the MorseCode object's
// buildCode() function to define the Morse Code alphabet according
// to the given input.
const string decodeWord(const string& inputCodedWord) const
// Preconditions: The MorseSystem needs to decode a given Morse Code
// word.
// Postconditions: This function calls the MorseCode object's
// interpret() function in order to parse and decode the given
// string representing a word in Morse Code.
{
return definitionSet.interpret(inputCodedWord);
}
const string encodeWord(const string& inputWord) const
// Preconditions: The MorseSystem needs to encode a given word in
// Morse Code.
// Postconditions: This function calls the MorseCode object's
// encodeWord() function in order to return the string of Morse
// Code symbols representing the given word.
{
return definitionSet.encodeWord(inputWord);
}
private:
MorseCode definitionSet;
};