SHOW:
|
|
- or go back to the newest paste.
1 | - | /* Basic Image Processing |
1 | + | /* Creature Feature */ |
2 | - | |
2 | + | |
3 | - | AUTHOR: Frank Valcarcel |
3 | + | |
4 | - | FSU ID: fav12 |
4 | + | |
5 | - | RECITATION SECTION NUMBER: 14 |
5 | + | |
6 | - | TA NAME: James McClain |
6 | + | |
7 | - | COURSE INFORMATION: COP 3330; T,R 3:35 - 4:50PM |
7 | + | |
8 | - | Project Number: 4 |
8 | + | |
9 | - | Due Date: October 31, 2012 |
9 | + | |
10 | - | |
10 | + | |
11 | - | SUMMARY |
11 | + | |
12 | #include "elf.h" | |
13 | - | |
13 | + | |
14 | - | |
14 | + | |
15 | - | INPUT |
15 | + | |
16 | ||
17 | - | |
17 | + | |
18 | - | BAD DATA CHECKING: |
18 | + | |
19 | - | When a file is streamed in, the file type is verified to insure the user has |
19 | + | |
20 | - | selected a PPM file, and that it is of type P3. At that time, the integers |
20 | + | |
21 | - | within the file header are validated larger than 0 and the stream operator |
21 | + | |
22 | - | also determines if enough "pixel" elements are available for the files width |
22 | + | |
23 | - | and height. On output, we truncate any pixel values to be between o and the |
23 | + | |
24 | - | specific image's depth value. |
24 | + | |
25 | - | |
25 | + | |
26 | - | OUTPUT |
26 | + | |
27 | - | The program will echoprint all input. The ostream << operator is overloaded |
27 | + | |
28 | - | to output the PPM file data to both the console and an output file. |
28 | + | |
29 | - | |
29 | + | |
30 | - | SAMPLE OUPUT |
30 | + | |
31 | - | |
31 | + | |
32 | - | |
32 | + | |
33 | - | |
33 | + | |
34 | - | DATA STRUCTURES |
34 | + | |
35 | title(); | |
36 | - | |
36 | + | |
37 | - | ASSUMPTIONS |
37 | + | |
38 | cin >> playerName; | |
39 | - | |
39 | + | |
40 | - | */ |
40 | + | |
41 | ||
42 | /* | |
43 | ||
44 | chooseCharacter(); | |
45 | ||
46 | sleep(5); | |
47 | system("clear"); | |
48 | ||
49 | */ | |
50 | ||
51 | cout << "Enter a filename, " << playerName << " the " | |
52 | << characterType(playersCharacter) << "... (include .txt)" << endl; | |
53 | ||
54 | cout << "Filename: "; | |
55 | cin >> fileName; | |
56 | ||
57 | while (!validateFileExtension(fileName)) { | |
58 | ||
59 | cout << "File type is invalid. TXT files only." << endl; | |
60 | cout << "Enter a filename to open (include .txt), or be slain! : "; | |
61 | cin >> fileName; | |
62 | ||
63 | fileIn.open( fileName.c_str() ); | |
64 | } | |
65 | ||
66 | if (fileIn.fail() ) { | |
67 | cout << "Failed to open input file." << endl; | |
68 | cout << "Enter a filename to open (include .txt), or be slain! : "; | |
69 | cin >> fileName; | |
70 | ||
71 | fileIn.open( fileName.c_str() ); | |
72 | } | |
73 | ||
74 | cout << "file opened" << endl; // DELETE ME!!! | |
75 | ||
76 | loadPlayers (fileIn, GoodGuys, BadGuys); | |
77 | ||
78 | cin >> move; | |
79 | ||
80 | fileIn.close(); | |
81 | ||
82 | return (0); | |
83 | } | |
84 | ||
85 | ||
86 | ||
87 | void loadPlayers (ifstream& is, vector<CreaturePtr>& GoodGuys, | |
88 | vector<CreaturePtr>& BadGuys) { | |
89 | ||
90 | int species, strength, hitpoints; | |
91 | int count = 0; | |
92 | string line; | |
93 | ||
94 | if( is.good() ){ | |
95 | ||
96 | for (int i = 0; i < 4; i++) { | |
97 | ||
98 | cout << "in good guy while loop... I should read data!" << endl; // DELETE ME!!! | |
99 | ||
100 | is >> species >> strength >> hitpoints; | |
101 | cout << species << strength << hitpoints; | |
102 | ||
103 | // if human type | |
104 | if(species == 0) | |
105 | { | |
106 | cout << "did I make it here? "; | |
107 | GoodGuys.push_back(new Human(strength, hitpoints)); | |
108 | count ++; | |
109 | cout << "Good Human " << i << endl; | |
110 | } | |
111 | // if cyberdemon type | |
112 | else if(species == 1) | |
113 | { | |
114 | GoodGuys.push_back(new CyberDemon(strength, hitpoints)); | |
115 | count ++; | |
116 | cout << "Good CyberDemon " << i << endl; | |
117 | } | |
118 | // if balrog type | |
119 | else if(species == 2) | |
120 | { | |
121 | GoodGuys.push_back(new Balrog(strength, hitpoints)); | |
122 | count ++; | |
123 | cout << "Good Balrog " << i << endl; | |
124 | } | |
125 | // if elf type | |
126 | else if(species == 3) | |
127 | { | |
128 | GoodGuys.push_back(new Elf(strength, hitpoints)); | |
129 | count ++; | |
130 | cout << "Good Elf " << i << endl; | |
131 | } | |
132 | // if data is invalid | |
133 | else { | |
134 | cout << is << " "; | |
135 | cout << "Error in file. Invalid creature. " << endl; | |
136 | return; | |
137 | }// end else | |
138 | } | |
139 | ||
140 | if (count >= 4) { | |
141 | ||
142 | for (int i = 0; i < 4; i++) { | |
143 | ||
144 | cout << "in bad guy loop... I should read data!" << endl; // DELETE ME!!! | |
145 | ||
146 | is >> species >> strength >> hitpoints; | |
147 | ||
148 | if (species > 0) { | |
149 | cout << "bad species greater than zero" << endl; | |
150 | } | |
151 | ||
152 | else { | |
153 | cout << "Error in file. Invalid creature. " << endl; | |
154 | return; | |
155 | }// end else | |
156 | } | |
157 | } | |
158 | } | |
159 | } |