-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
59 lines (49 loc) · 1.66 KB
/
main.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
//
// Created by Arnav on 3/11/2022.
//
#include <iostream> // library for reading & writing from the console/keyboard
#include <fstream> // accesses your hard drive
#include <vector>
#include <iostream>
#include <string>
#include <cassert>
#include "board.h"
#include "section.h"
int main(int argc,char** argv) {
std::string input=argv[1];
std::string output=argv[2];
std::string starPerZone=argv[3];//number(CONVERT TO INT)
std::string outputMode=argv[4];//count or print
std::string solutionMode=argv[5];
std::ifstream infile(input);//READING DATA
std::ofstream outfile(output);//WRITING DATA
if(!infile){
std::cerr << "Could not open"<<argv[1]<<" to read\n";
return 1;
}
if(!outfile){
std::cerr << "Could not open"<<argv[2]<<" to write\n";
return 1;
}
int ysize,xsize;
int starPer=std::stoi(starPerZone);//converts the string to int
infile>>ysize>>xsize;
board newBoard(ysize,xsize,starPer);//creates board with x and y size
int totalCount=0;
std::string letterIdentity;
int numOfSpots=0;
//adds all of the data to a vector
while(infile>>letterIdentity>>numOfSpots){
section sector(letterIdentity,numOfSpots,starPer);
totalCount+=numOfSpots;
for(int i=0;i<numOfSpots;i++){
int xCoor,yCoor;
infile>>xCoor>>yCoor;
std::vector<int> oneCoor={xCoor,yCoor};
sector.addPoint(oneCoor);
}
newBoard.addSection(sector);
}
newBoard.startRec(outputMode,solutionMode,outfile);
return 0;
}