NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

#include <iostream>
#include <string.h>
#include <cstdlib>
#include <winable.h>


using namespace std;

HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);

static int p = 0; // Variabila globala

class rezervare_autobuz
{
char nr_autobuz[5],sofer[20],ora_sosirii[5],ora_plecarii[5],oras_plecare[25],oras_sosire[25],locuri[8][4][15];

public:
void adaugare_autobuz();
void rezervare();
void init_loc();
void afisare_locuri();
void disponibil();
void scaun_autobuz(int i);
}autobuz[10];

void chenar(int ch)
{
for (int i=80;i>0;i--)
{
cout<<ch;
}
}

void rezervare_autobuz::adaugare_autobuz()
{
cout<<"Numar autobuz: ";
cin>>autobuz[p].nr_autobuz;
cout<<"nNume sofer: ";
cin>>autobuz[p].sofer;
cout<<"nOra plecarii: ";
cin>>autobuz[p].ora_plecarii;
cout<<"nOra sosirii: ";
cin>>autobuz[p].ora_sosirii;
cout<<"nOras plecare: ttt";
cin>>autobuz[p].oras_plecare;
cout<<"nOras sosire: ttt";
cin>>autobuz[p].oras_sosire;
autobuz[p].disponibil;
p++;
}

void rezervare_autobuz::rezervare()
{
int loc;
char numar[5];
top:
cout<<"Numar autobuz: ";
cin>>numar;
int n;
for(n=0;n<=p;n++)
{
if(strcmp(autobuz[n].nr_autobuz,numar)==0)
break;
}
while(n<=p)
{
cout<<"nNumar loc: ";
cin>>loc;
if(loc>>32)
{
SetConsoleTextAttribute(console, 12);
cout<<"nSunt doar 32 de locuri in autobuz";
SetConsoleTextAttribute(console, 15);
}else
{
if(strcmp(autobuz[n].locuri[loc/4][(loc%4)-1], "Disponibil")==0)
{
cout<<"nNumele pasagerului: ";
cin>>autobuz[n].locuri[loc/4][(loc%4)-1];
break;
}else
{
SetConsoleTextAttribute(console, 12);
cout<<"nAcest loc este deja rezervat";
SetConsoleTextAttribute(console, 15);
}
}
}
if(n>p)
{
SetConsoleTextAttribute(console, 12);
cout<<"nAti gresit numarul autobuzului";
SetConsoleTextAttribute(console, 15);
goto top;
}

}

void rezervare_autobuz::disponibil()
{
for(int i=0;i<8;i++)
{
for(int j=0;j<4;j++)
{
strcpy(autobuz[p].locuri[i][j], "Disponibil");
}
}
}

void rezervare_autobuz::afisare_locuri()

{
int n;
char numar[5];
cout<<"nScrieti numarul autobuzului: ";
cin>>numar;
for(n=0;n<=p;n++)
{
if(strcmp(autobuz[n].nr_autobuz,numar)==0)
break;
}
while (n<=p)
{
chenar('*');
cout<<"Numar autobuz: t"<<autobuz[n].nr_autobuz<<"nSofer: t: "<<autobuz[n].sofer<<"nOra plecarii: t"<<autobuz[n].ora_plecarii
<<"nOra sosirii: t"<<autobuz[n].ora_sosirii<<"nOras plecare: t"<<autobuz[n].oras_plecare<<"nOras sosire: t"<<autobuz[n].oras_sosire<<"n";
chenar('*');
autobuz[0].scaun_autobuz(n);
int a=1;
for(int i=0;i<8;i++)
{
for(int j=0;j<4;j++)
{
a++;
if(strcmp(autobuz[n].locuri[i][j], "Disponibil")!=0)
{
SetConsoleTextAttribute(console, 12);
cout<<"nLocul numarul "<<(a-1)<<" este rezervat de "<<autobuz[n].locuri[i][j]<<".";
SetConsoleTextAttribute(console, 15);
}
}
}
break;
}
if(n>p)
{
SetConsoleTextAttribute(console, 12);
cout<<"Introduceti numarul corect al autobuzului: ";
SetConsoleTextAttribute(console, 15);
}
}

void rezervare_autobuz::scaun_autobuz(int l)
{
int s=0;p=0;
for(int i=0;i<8;i++)
{
cout<<"n";
for(int j=0;j<4;j++)
{
s++;
if(strcmp(autobuz[l].locuri[i][j], "Disponibil")==0)
{
cout.width(5);
cout.fill(' ');
cout<<s<<".";
cout.width(10);
cout.fill(' ');
//if(autobuz[l].locuri[i][j] == "Disponibil")
//{
SetConsoleTextAttribute(console, 10);
cout<<autobuz[l].locuri[i][j];
SetConsoleTextAttribute(console, 15);
/*}
else
{
SetConsoleTextAttribute(console, 12);
cout<<autobuz[l].locuri[i][j];
SetConsoleTextAttribute(console, 15);
}*/
p++;
}
else
{
cout.width(5);
cout.fill(' ');
cout<<s<<".";
cout.width(10);
cout.fill(' ');
SetConsoleTextAttribute(console, 12);
cout<<autobuz[l].locuri[i][j];
SetConsoleTextAttribute(console, 15);
}
}
}
cout<<"nSunt "<<p<<" locuri libere in autobuzul numarul "<<autobuz[l].nr_autobuz;
}

void rezervare_autobuz::disponibil()
{
for(int n=0;n<p;n++)
{
chenar('*');
cout<<"Autobuzul numarul t"<<autobuz[n].nr_autobuz<<"nSofer: t"<<autobuz[n].sofer<<"nOra plecarii: t"<<autobuz[n].ora_plecarii
<<"nOra sosirii: t"<<autobuz[n].ora_sosirii<<"nOras pleacare: tt"<<autobuz[n].oras_plecare<<"ttOras sosire: ttt"
<<autobuz[n].oras_sosire<<"n";
chenar('*');
chenar('_');
}
}

int main()
{
system("cls");
int w;
while(1)
{
cout<<"nnnnn";
cout<<"ttt1.Adaugare autobuznttt"
<<"2.Rezervare locnttt"
<<"3.Afisare locurinttt"
<<"4.Autobuze disponibilenttt"
<<"5.Iesire";
cout<<"nttAlegeti una dintre optiunile de mai sus:-> ";
cin>>w;
switch(w)
{
case '1': autobuz[p].adaugare_autobuz();
break;
case '2': autobuz[p].rezervare();
break;
case '3': autobuz[p].afisare_locuri();
break;
case '4': autobuz[p].disponibil();
break;
case '5': exit(0);
}
}
return 0;
}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.