Skip to content
This repository has been archived by the owner on Aug 11, 2024. It is now read-only.

Commit

Permalink
U | Update calc, error, etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
FTS427 committed Jan 14, 2024
1 parent 962b7e9 commit b4c5c30
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
21 changes: 14 additions & 7 deletions src/include/ecp.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@ using namespace std;

int error(){
printf("\033[1,31mERROR!\033[0m\a\n");
return 0;
return 1;
}

void clear(){system("clear");}
int clear(){
system("clear");
return 0;
}

void print(const char T[],string color,bool i){
if(i==true){
Expand All @@ -30,7 +33,8 @@ void print(const char T[],string color,bool i){
cout<<"\033[35m"<<T<<"\033[0m\n";
if(color=="white")
cout<<"\033[0m"<<T<<"\033[0m\n";
error;
else
error();
}
if(i==false){
if(color=="none")
Expand All @@ -49,9 +53,11 @@ void print(const char T[],string color,bool i){
cout<<"\033[35m"<<T<<"\033[0m";
if(color=="white")
cout<<"\033[0m"<<T<<"\033[0m";
error;
else
error();
}
error;
else
error();
}

void line(const char S[],int l,string color,bool i){
Expand All @@ -62,7 +68,7 @@ void line(const char S[],int l,string color,bool i){
}
print(S,color,i);
}
error;
error();
}

void dash(const char T[]){
Expand All @@ -82,7 +88,8 @@ void boxout(const char T[],string bc,string tc,bool i){
line("-",l+2,bc,false);
print("+",bc,i);
}
error;
else
error();
}
void hy(const char T[]){cout<<"==> "<<T<<endl;}
char q;
6 changes: 5 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
//Preview, be careful

#include "./include/ecp.h"

// Include modules
#include "./module/calc.cpp"
#include "./module/maxn.cpp"
#include "./module/minn.cpp"
Expand All @@ -25,9 +27,12 @@ int main(){
if (q=='1'){
int a,b;
char o;
print("calc> ","white",false);
cin >>a>>o>>b;
while (a!='0'&&b!='0'&&o!='c'){
cout << calc(a,b,o) <<endl;
print("calc> ","white",false);
cin >>a>>o>>b;
}
}
if (q=='2')
Expand All @@ -36,7 +41,6 @@ int main(){
C();
if (q=='4')
D();
//if (u=='5')E();
if (q=='E'||q=='e')
break;
if (q=='A'||q =='a'){
Expand Down
1 change: 1 addition & 0 deletions src/module/calc.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <cstddef>
int calc(int fn, int bn, char o){
if (o=='+')
return fn+bn;
Expand Down

0 comments on commit b4c5c30

Please sign in to comment.