Написать программу LCD-дисплей — C++(Си)

#include <iostream>
#include <windows.h>
#include <string>
#include <conio.h>
 
using namespace std;
 
class cLCDisplay{
public:
void Display(string st);
void Null(char h_symb, char v_symb, int st_x, int st_y, int size);
void One(char h_symb, char v_symb, int st_x, int st_y, int size);
void Two(char h_symb, char v_symb, int st_x, int st_y, int size);
void Three(char h_symb, char v_symb, int st_x, int st_y, int size);
void Four(char h_symb, char v_symb, int st_x, int st_y, int size);
void Five(char h_symb, char v_symb, int st_x, int st_y, int size);
void Six(char h_symb, char v_symb, int st_x, int st_y, int size);
void Seven(char h_symb, char v_symb, int st_x, int st_y, int size);
void Eight(char h_symb, char v_symb, int st_x, int st_y, int size);
void Nine(char h_symb, char v_symb, int st_x, int st_y, int size);
 
void Symbol_c(char h_symb, char v_symb, int st_x, int st_y, int size);
void Symbol_e(char h_symb, char v_symb, int st_x, int st_y, int size);
 
void CheckBorder();
private:
COORD a;
HANDLE console;
char symbol;
};
 
void cLCDisplay::CheckBorder(){
if (a.X>79){
a.X=5;
a.Y=23;
}
}
 
void cLCDisplay::Null(char h_symb, char v_symb, int st_x, int st_y, int size){
console=GetStdHandle(STD_OUTPUT_HANDLE);
 
a.X=st_x;
a.Y=st_y;
int i=0;
while (i SetConsoleCursorPosition(console,a);
cout< i++;
a.X++;
CheckBorder();
}
 
a.X=st_x;
a.Y=(size+size+3)+st_y;
i=0;
while (i SetConsoleCursorPosition(console,a);
cout< i++;
a.X++;
}
 
a.X=size+st_x;
a.Y=st_y;
i=0;
while (i<(size+size+2)){ // вертик права
a.Y++;
SetConsoleCursorPosition(console,a);
cout< i++;
}
 
a.X=st_x-1;
a.Y=st_y;
i=0;
while (i<(size+size+2)){ // вертик лев
a.Y++;
SetConsoleCursorPosition(console,a);
cout< i++;
}
}
 
void cLCDisplay::One(char h_symb, char v_symb, int st_x, int st_y, int size){
console=GetStdHandle(STD_OUTPUT_HANDLE);
 
a.X=st_x;
a.Y=st_y;
int i=0;
while (i SetConsoleCursorPosition(console,a);
cout< a.Y++;
i++;
}
}
 
 
... 
 
 
void cLCDisplay::Display(string st){
int const size=6;
int start_x=2, start_y=5;
for (int i=0; i if (st[i]=='0') Null('-','|',start_x,start_y,size);
if (st[i]=='1') One('-','|',start_x,start_y,size);
if (st[i]=='2') Two('-','|',start_x,start_y,size);
if (st[i]=='3') Three('-','|',start_x,start_y,size);
if (st[i]=='4') Four('-','|',start_x,start_y,size);
if (st[i]=='5') Five('-','|',start_x,start_y,size);
if (st[i]=='6') Six('-','|',start_x,start_y,size);
if (st[i]=='7') Seven('-','|',start_x,start_y,size);
if (st[i]=='8') Eight('-','|',start_x,start_y,size);
if (st[i]=='9') Nine('-','|',start_x,start_y,size);
if (st[i]=='1') start_x+=-6;
 
if (st[i]=='c') Symbol_c('-','|',start_x,start_y,size);
if (st[i]=='e') Symbol_e('-','|',start_x,start_y,size);
 
start_x+=10;
 
}
}
 
int main()
{
char str[21]="Введите инструкцию: ";
CharToOem(str,str);
string st;
cLCDisplay Number;
while (true){
cout< getline(cin,st);
Number.Display(st);
getch();
system("cls");
}
return 0;
}

Leave a Comment