This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #pragma once | |
| #include "Graph.h" | |
| #include <vector> | |
| #include <iostream> | |
| #include <algorithm> | |
| namespace Graph_lib { | |
| struct BarGraph : public Shape { | |
| BarGraph(const int graphWidth, const int graphHeight, const vector<double>& values); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include "BarGraph.h" | |
| #include "std_lib_facilities.h" | |
| Graph_lib::BarGraph::BarGraph(const int graphWidth_, const int graphHeight_, const vector<double>& values_) | |
| { | |
| graphWidth = graphWidth_; | |
| graphHeight = graphHeight_; | |
| values = values_; | |
| const std::size_t valuesAmount = values.size(); | |
| int barWidth = (graphWidth / valuesAmount); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include "Simple_window.h" | |
| #include "Graph.h" | |
| #include "BarGraph.h" | |
| int main() | |
| { | |
| // setup the position of top left corner for the window | |
| Point tl{ 100,100 }; | |
| // make a simple window |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include "Simple_window.h" | |
| #include "Graph.h" | |
| #include "Arc.h" | |
| using namespace Graph_lib; | |
| class Smiley : public Circle { | |
| public: | |
| using Circle::Circle; | |
| void draw_lines() const; | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const char* cat_dot(const char* s1, const char* s2) { | |
| int s1Len = len(s1); | |
| int s2Len = len(s2); | |
| char* concantinated = new char[s1Len + s2Len - 2]; | |
| for (int i = 0; i < s1Len; ++i) { | |
| concantinated[i] = s1[i]; | |
| } | |
| concantinated[s1Len] = '.'; | |
| int x = 0; | |
| for (int i = s1Len+1; i <= s1Len+s2Len+1; ++i) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int len(const char* s) { | |
| int size = 0; | |
| while (*++s) | |
| ++size; | |
| return size; | |
| } | |
| char* strdup(const char* s) { | |
| int length = len(s); | |
| char* newChar = new char[length]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| char* findx(const char* s, const char* x) { | |
| int xLength = -1; | |
| while (true) { | |
| if (x[xLength+1] == 0) { | |
| break; | |
| } | |
| ++xLength; | |
| } | |
| int sLength = 0; | |
| while (true) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| char* stdup(const char* string) { | |
| int size = 0; | |
| while (true) { | |
| if (string[size] == 0) | |
| break; | |
| ++size; | |
| } | |
| char* newString = new char[size]; | |
| for (int i = 0; i <= size; ++i) { | |
| newString[i] = string[i]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include "std_lib_facilities.h" | |
| void toLower(char* s) { | |
| int size = -1; | |
| int ind = 0; | |
| while (true) { | |
| if (s[size] == 0) | |
| break; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include "std_lib_facilities.h" | |
| struct Date{ | |
| int year; | |
| int month; | |
| int day; | |
| }; | |
| class Book { | |
| public: |
NewerOlder