Caesar Cipher - Object Oriented Programming help

Hi guys, I need some help with this program. I've already written the command line interface myself. (C++, but runs through the command line) But I'm stuck with actually implementing the object oriented method with what I already have, the algorithm for checking if a letter a - z (lowercase only is valid), and the algorithms for decryption and encryption.

This is the assignment in full detail.

https://drive.google.com/file/d/0B8HcpK1tdNXGQXVuNlIza2R0N2M/view?usp=sharing

We are explicitly only able to use cstrings outside of the main function. The big problem that I'm worried about after all of this (sigh) is being able to take the user's input from the command line (as an argument), and apply it to the shift private member variable of the CaesarCipher class.

Please help me with this if you can. This assignment is due at midnight, and I've tried looking everywhere for examples of this, but was unable to find any that detailed writing a Caesar Cipher like this.

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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
// ---------------------------------------------------------------------------
// Name: Hidden
// Course:
// Assignment: Command Line
// Description: Implements a main that supports a command
// -line interface. Provides a "--help" option that displays
// the API. (Encrypt and Decrypt)
// ---------------------------------------------------------------------------

#include <iostream>
#include <cstring>
	
using namespace std;

class CaesarCipher

{
    
    
private:
    
    int shift;
    
public:
    
    CaesarCipher();
    
    CaesarCipher (int size);
    
    void encrypt (char letters[]);
    
    void decrypt (char letters[]);
    
    bool isValid (char letters[]);
    
    
};



//***************************************************************************
// Main Function (Driver) - Command Line Interface
//***************************************************************************


int main (int argc, char* argv[])

{
	
	cout << "\n\n";
	
	cout << "---------------------------------------" << "\n";
    cout << "Caesar Cipher - Command Line Interface  " << "\n";
	cout << "---------------------------------------" << "\n";

	cout << "\n\n";

    
    
    
    
    if (argc > 2)
        
    { 
    
    	if (strcmp (argv[1], "--help") == 0)
    	
    	{
    		
    		cout << "Usage: cipher [shift] -e | -d textwithnospaces\n\n";
	
		}
		
			else if (strcmp (argv[1], "-e") == 0)
			
			{
				
				cout << "Encrypt" << "\n\n";
				
				

			}
			
			else if (strcmp (argv[1], "-d") == 0)
			
			{
				
				
				if (argc != 3)
				
				{
					
					cout << "Usage: cipher [shift] -e | -d textwithnospaces\n\n";
				
				}
				
				else
				
				{
					
					cout << "Decrypt" << "\n\n";
					
				}
				
			}
				
				else
			
				{
				
				cout << "Usage: cipher [shift] -e | -d textwithnospaces\n\n";

				}

			}
			
			
        
    
    
    else 
    
    {
	
		cout << "Usage: cipher [shift] -e | -d textwithnospaces\n\n";
	
	}
    
    
    return 0;
    
	
}

//***************************************************************************
// Member Functions - CaesarCipher (Class Definition)
//***************************************************************************


CaesarCipher::CaesarCipher (int size)

{
    
    shift = size;
    
}

void CaesarCipher::encrypt(char letters[])

{
    
    for (int i = 0; i < shift; i++)
        
    {
        
        letters[i] = letters[i] + shift; // +=
        
    }
        
    
}

void CaesarCipher::decrypt(char letters[])

{
    
    
    
}
Last edited on
that cout statement is indented in the same place as the rest of them btw, it just shows up that way on here for some reason.
Topic archived. No new replies allowed.