-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcowsay.cpp
More file actions
87 lines (81 loc) · 2.25 KB
/
Copy pathcowsay.cpp
File metadata and controls
87 lines (81 loc) · 2.25 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#include <iostream>
#include <string>
#include "Cow.h"
#include "Dragon.h"
#include "IceDragon.h"
#include "HeiferGenerator.cpp"
using namespace std;
int main(int argc, const char** argv)
{
HeiferGenerator gen;
string message;
if(argv[1] == "-l")
{
//list out cows
cout << "Cows Available: ";
for(Cow* currentCow: gen.getCows())
{
cout << currentCow->getName() << " ";
}
}
else if(argv[1] == "-n")
{
//assign next argument to message
for (int i = 3; i < argc; i++)
{
message = argv[i];
if (i < argc - 1)
{
cout << message;
}
else if (i = argc - 1)
{
cout << message << endl;
}
}
Cow calledCow = Cow(argv[2]);
try
{
for (Cow *currentCow: gen.getCows())
{
if (currentCow->getName() == argv[2])
{
if(argv[2] == "dragon")
{
Dragon calledDragon = Dragon(argv[2],calledCow.getImage());
cout << calledDragon.getImage() << endl;
cout << endl;
cout << "This dragon can breathe fire." << endl;
cout << endl;
}
else if(argv[2] == "ice-dragon")
{
IceDragon calledDragon = IceDragon(argv[2], calledCow.getImage());
cout << calledDragon.getImage() << endl;
cout << endl;
cout << "This dragon cannot breathe fire." << endl;
cout << endl;
}
else
{
calledCow = *currentCow;
cout << calledCow.getImage() << endl;
}
}
}
cout << endl;
}
catch (...)
{
cout << "Could not find " << argv[2] << " cow!" << endl;
}
}
else
{
for (int i = 1; i < argc; i++)
{
message = argv[i];
cout << message;
}
}
}