-
Notifications
You must be signed in to change notification settings - Fork 1
/
QualityOfLife.h
159 lines (138 loc) · 3.71 KB
/
QualityOfLife.h
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#pragma once
#include<iostream>
#include <string>
#include<limits>
#include <iomanip> // For setw() func.
#include"audio.h"
#undef max
// This somehow fixes an error code that could come from "max()" in the cin.ignore function, here's where I got it from: [https://stackoverflow.com/a/21959303].
using namespace std;
// The following two libraries and standards are for the time...
#include <chrono>
#include <thread>
using std::this_thread::sleep_for;
using std::chrono::milliseconds;
// Quality Of Life Functions:
// Colors.
void white() {
system("color f");
}
void purple() {
system("color d");
}
// Spelled like this on purpose!
void yello() {
system("color e");
}
// Just to prettify stuff...
void boundary() {
cout << endl;
string load = "*****************************************************************";
short x = 0;
while (load[x] != '\0') {
cout << load[x];
sleep_for(milliseconds(50));
x++;
}
cout << endl;
}
// Creates the three dot loading thing...
void pause() {
sleep_for(milliseconds(500)); cout << ".";
sleep_for(milliseconds(500)); cout << ".";
sleep_for(milliseconds(500)); cout << ".";
sleep_for(milliseconds(500)); cout << endl;
}
// Clears the screen.
void cls() {
system("cls");
}
// Checks if user input is Positive...
bool isPos(int num) {
if (num >= 0) {
return true;
}
else {
return false;
}
}
// Checks if user input is a double... (Using the limits library, and knoweledge from the internet)
bool isDouble(double num) {
if (cin.fail()) {
// Input could not be interpreted as a double
return false;
}
else {
// Input is a valid double
return true;
}
}
void hearts(short amnt) {
cout << "\n";
string heart = "\003";
for (short i = 0; i < amnt; i++) {
cout << heart[0];
sleep_for(milliseconds(1));
}
cout << "\n";
}
// Self explanitory...112
void easterEgg() {
yello();
cls();
egg();
hearts(112);
// Sets the given text into a string var.
string Speech = "The coffee flowed from the machine in a smooth, steady stream, each droplet glistening in the light.\nIt was like a dance, a beautiful, mesmerizing performance that drew the eye and captured the imagination.\nAs it made its way into the cup, the coffee seemed to come alive, filling the air with its rich, aromatic scent.\nIt was a fragrance that spoke of comfort and warmth, of cozy nights by the fire and quiet moments of reflection.\n";
int x = 0;
// Prints out the words letter-by-letter until the end character '\0'.
while (Speech[x] != '\0') {
cout << Speech[x];
sleep_for(milliseconds(50));
x++;
}
hearts(112);
system("pause");// This give the user enough time to read.
cls();
white();
}
// Counts how many digits are in a single double variable.
int _digCount(double cPrice) {
int x = int(cPrice);
return (to_string(x).length());
}
// To find the longest digit in an array.
int digCount(double cPrice[]) {
int digCount = 0;
for (short i = 0; i < 5; i++) {
if (digCount < to_string(cPrice[i]).length()) {
digCount = to_string(cPrice[i]).length();
}
}
return digCount;
}
// To find the longest coffee name in an array.
int charCount(string cTypes[]) {
int strSize = 0;
for (short i = 0; i < 5; i++) {
if (strSize <= cTypes[i].length()) {
strSize = cTypes[i].length();
}
}
return strSize;
}
// Uses the counted digits to know how many to print out... plus 3 for the dot and two decimal points.
void print(string str, double cPrice, int i) {
string x = str, y;
short n = 0;
while (n < (_digCount(cPrice) + 3)) {
y += x[n];
n++;
}
cout << setw(i) << y;
}
// Clears out a potentially corrupted cin.
void cinFlush() {
cin.clear(); // Clears any error flags in the input stream.
cin.ignore(numeric_limits<streamsize>::max(), '\n'); // Ignores all characters up until the newline character.
}