-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFigure.cpp
More file actions
50 lines (45 loc) · 1.34 KB
/
Figure.cpp
File metadata and controls
50 lines (45 loc) · 1.34 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
//
// Created by georg on 4/22/2017.
//
#include "Figure.h"
#include <iostream>
#include <sstream>
#include <cstdlib>
Figure::Figure() {
fill = "white";
stroke = "black";
strokeWidth = 1;
}
void Figure::setInfo(std::string line) {
std::string word;
std::istringstream inputStream(line);
while (inputStream >> word) {
if(word.find("fill=") != std::string::npos) {
std::string color;
for (int i = 6; i < word.size() - 1; i++)
color += word[i];
fill = color;
}
if(word.find("stroke=") != std::string::npos) {
std::string color;
for (int i = 8; i < word.size() - 1; i++) {
color += word[i];
}
stroke = color;
}
if(word.find("stroke-width=") != std::string::npos){
std::string number;
for (int i = 14; i < word.size() - 1; i++)
number += word[i];
strokeWidth = atoi(number.c_str());
}
}
}
void Figure::print() const {
std::cout << fill << ' ' << stroke << ' ' << strokeWidth << std::endl;
}
void Figure::translate(std::string line) {}
void Figure::printToFile(std::ofstream& os) {
os << "\t\tfill=\"" << fill << "\" stroke=\"" << stroke << "\" stroke-width=\"" << strokeWidth << "\" />" << std::endl;
os << std::endl;
}