-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlanet.cpp
59 lines (53 loc) · 1.11 KB
/
Planet.cpp
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
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <fstream>
#include <cstdlib>
#include "Planet.h"
#include "Map.h"
using namespace std;
planet::planet() {
srand(time(NULL));
size = (1+rand()%16)/2;
cap = size*.5*1000+rand()%1000;
fuelNeeded = 50000;
string name1 = "";
string line;
string arr[3125];
ifstream fin("four_letter_words.txt");
if(fin.fail()) {
cout << "Planet name file not found" << endl;
}
int j = 0;
while(getline(fin, line)) {
arr[j] = line;
j++;
}
for(int i = 0; i<6; i++) {
int r = rand()%2+1;
if(r == 1) {
name1 += char(rand()%26+65);
} else {
name1 += to_string(rand()%10);
}
}
name = name1 + "-" +arr[rand()%3125];
}
int planet::getSize() {
return size;
}
string planet::getName() {
return name;
}
int planet::getCap() {
return cap;
}
int planet::getFuelForPlanet() {
return fuelNeeded;
}
void planet::setFuelForPlanet(int fuel) {
fuelNeeded = fuel*fuel/1000000+fuel;
}