Skip to content

Instantly share code, notes, and snippets.

View jackthehat8's full-sized avatar

Jack Howlett jackthehat8

View GitHub Profile
@jackthehat8
jackthehat8 / BarGraph.h
Created December 18, 2020 06:00
Task 1 | 14 - Graphing Functions and Data
#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);
@jackthehat8
jackthehat8 / BarGraph.cpp
Created December 18, 2020 06:00
Task 1 | 14 - Graphing Functions and Data
#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);
@jackthehat8
jackthehat8 / main.cpp
Created December 18, 2020 06:00
Task 1 | 14 - Graphing Functions and Data
#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
@jackthehat8
jackthehat8 / Main.cpp
Created December 18, 2020 03:41
Task 1 | 13 - Graphics Class Design
#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;
};
@jackthehat8
jackthehat8 / Main.cpp
Created December 18, 2020 01:23
Task 3 | 17 - Vectors and Arrays
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) {
@jackthehat8
jackthehat8 / main.cpp
Last active December 18, 2020 00:38
Task 1 | 17 - Vectors and Arrays
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];
@jackthehat8
jackthehat8 / main.cpp
Created December 17, 2020 21:39
Task 3 | 16 - Vector and Freestore
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) {
@jackthehat8
jackthehat8 / Main.cpp
Created December 17, 2020 21:00
Task 2 | 16 - Vector and Freestore
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];
@jackthehat8
jackthehat8 / main.cpp
Created December 17, 2020 20:43
Task 1 | 16 - Vector and Freestore
#include "std_lib_facilities.h"
void toLower(char* s) {
int size = -1;
int ind = 0;
while (true) {
if (s[size] == 0)
break;
@jackthehat8
jackthehat8 / main.cpp
Created December 17, 2020 15:35
Task 1 & 2 | 8 - class technicals
#include "std_lib_facilities.h"
struct Date{
int year;
int month;
int day;
};
class Book {
public: