TP KELOMPOK 09″

Baru2 ini saya n teman2 saya baru saja menyelesaikan tugas proyek yang diberikan oleh dosen.

saya n teman2 kebetulan membuat TP tentang antrian di Pemilu , yang berisi tentang pengantrian di pemilu yang baru saja berlangsung di negeri tercinta ini. semoga TP ini dapat menjadi referensi bagi temen2 yang ingin membuat sebuah program lebih jelasnya kami tampilkan juga source codennya sbb:

#include <iostream.h>
#include <conio.h>

class Data {
public:
Data();
char NoUrut[10];
char Nama[15];
char Kategori[10];
void setUrut(char* iktp);
void setNama(char *inama);
void setKategori(char *ikaetegori);
char* getUrut();
char* getNama();
char* getKategori();
};

class antrian {
private :
int max;
int fcount;
int xcount;
Data ix[10];
Data iy[10];

public :
antrian();
void buatData(char*,char*,char*);
void menu ();
bool isFull();
void deletekiri();
void deletekiril();
void baca();
void buatLoket(int x, int y,char *nama);
void buatKotak(int x,int y, int panjang, int lebar);
void buatKotakAntri(int x,int y, int panjang, int lebar);
void tim();

};

Data::Data(){
}
antrian::antrian(){
max=10;
fcount=0;
xcount=0;
}

void Data::setUrut(char* iUrut)
{
strcpy(NoUrut,iUrut);
}
void Data::setNama(char *inama)
{
strcpy(Nama,inama);
}

void Data::setKategori(char *ikategori)
{
strcpy(Kategori,ikategori);
}
char* Data::getUrut()
{
return NoUrut;
}
char* Data::getNama()
{
return Nama;
}
char* Data::getKategori()
{
return Kategori;
}

void antrian::buatData(char* x,char* y,char* w) {
if (w[0]== ‘l’ ||w[0]== ‘L’ ){
if (!isFull()){
fcount++;
ix[fcount-1].setUrut(x);
ix[fcount-1].setNama(y);
ix[fcount-1].setKategori(w);
}
else cout<<”pembuatan Antian gagal\n”;
}
else if(w[0]==’p'||w[0]== ‘P’)
{
if (!isFull()){
xcount++;
iy[xcount-1].setUrut(x);
iy[xcount-1].setNama(y);
iy[xcount-1].setKategori(w);
}
}
else cout<<”pembuatan Antian gagal\n”;

}

void antrian::menu () {
buatKotak(2,1,75,4);
gotoxy(15,3);
textcolor(123);
cprintf(“         PROGRAM ANTRIAN PEMILU DI KOTA GEDHE\n\n”);
cout<<’\n’;
;

buatKotak(50,18,27,25);
buatLoket(5,14,”BILIK I”);
buatLoket(30,14,”BILIK II”);
textcolor(123);
gotoxy(18,7); cprintf(“GAMBAR ANTRIAN\n”);
textcolor(123);
gotoxy(58,7);cprintf(“MENU KONTROL\n”);
textcolor(LIGHTGREEN);
gotoxy(54,11); cprintf(“1  Tambah antrian\n”);
gotoxy(54,12); cprintf(“2  Layani antrian bilik 1\n”);
gotoxy(54,13); cprintf(“3  Layani antrian bilik 2\n”);
gotoxy(54,14); cprintf(“0. Keluar\n”);
textcolor(WHITE);
gotoxy(54,16); cprintf(“Masukkan Pilihan :”);
textcolor(LIGHTBLUE);
gotoxy(57,33); cprintf(“Nama Kelompok :”);
textcolor(12);
gotoxy(51,34); cprintf(“1. Roni Wijaya “);
textcolor(12);
gotoxy(51,35); cprintf(“2. Disman”);
textcolor(12);
gotoxy(51,36); cprintf(“3. Ardan nuri P.A.W”);
textcolor(12);
gotoxy(51,37); cprintf(“4. Nur Cahyo K”);
textcolor(12);
gotoxy(51,38); cprintf(“5. Bestian N.A”);

}

bool antrian::isFull(){
if (fcount==(max-1 )) return true;
else return false;
}

void antrian::deletekiri(){
if (fcount!=0){
fcount–;
for(int i=0;i<fcount;i++)
ix[i]= ix[i+1];
}
else {
gotoxy(3,44);cout<<”antrian kosong “;
gotoxy(3,45);cout<<”Tekan sembarang tombol”;
getch();
// goto menu;
}
}

void antrian::deletekiril(){
if (xcount!=0){
xcount–;
for(int m=0;m<xcount;m++)
iy[m]= iy[m+1];
}
else {
gotoxy(3,44);cout<<”antrian kosong “;
gotoxy(3,45);cout<<”Tekan sembarang tombol”;
getch();
// goto menu;
}

}

void antrian::baca(){
int n,n1,n2,n3,n4;
int l,l1,l2,l3,l4;
n = 14; n1 = n+1; n2 = n+2; n3 = n+3; n = n+4;
l = 14; l1 = l+1; l2 = l+2; l3 = l+3; l = l+4;
textcolor(WHITE);
for(int i=0;i<fcount;i++){
buatKotakAntri(5,n1,14,2);
gotoxy(10,n2); cprintf(ix[i].getNama());
n+=3; n1+=3; n2+=3; n3+=3; n4+=4;
}

for(int j=0;j<xcount;j++){
buatKotakAntri(30,l1,14,2);
gotoxy(35,l2); cprintf(iy[j].getNama());
l+=3; l1+=3; l2+=3; l3+=3; l4+=4;
}
}

void antrian::buatKotak(int x,int y, int panjang, int lebar){

gotoxy(x,y); cout<<char(201); //garis kiri
gotoxy(x+panjang,y);cout<<char(187);
gotoxy(x,lebar+y);cout<<char(200);
gotoxy(x+panjang,y+lebar);cout<<char(188);

for(int i=x+1;i<x+panjang;i++)
{
gotoxy(i,y);cout<<char(205);     //garis horizontal atas
gotoxy(i,y+lebar);cout<<char(205); //garis horizontal bawah
}

for(int k=y+1;k<y+lebar;k++)
{
gotoxy(x,k);cout<<char(186);     //garis vertikal
gotoxy(x+panjang,k);cout<<char(186);
}

}

void antrian::buatKotakAntri(int x,int y, int panjang, int lebar){

gotoxy(x,y);cout<<char(218); //garis kiri atas
gotoxy(x+panjang,y);cout<<char(191); //garis kanan atas
gotoxy(x,lebar+y);cout<<char(192); //garis kiri bawah
gotoxy(x+panjang,y+lebar);cout<<char(217);//garis kanan bawah

for(int i=x+1;i<x+panjang;i++)
{
gotoxy(i,y);cout<<char(196);     //garis horizontal atas
gotoxy(i,y+lebar);cout<<char(196); //garis horizontal bawah
}

for(int k=y+1;k<y+lebar;k++)
{
gotoxy(x,k);cout<<char(179);     //garis vertikal
gotoxy(x+panjang,k);cout<<char(179);
}

}

void antrian::buatLoket(int x, int y,char* nama){
int panjang,pos;
panjang = strlen(nama)/2;
pos=(7-panjang);
gotoxy(x,y-1);cout<<char(179);
gotoxy(x+14,y-1);cout<<char(179);
gotoxy(x,y);cout<<char(192); //garis kiri bawah
gotoxy(x+14,y);cout<<char(217);//garis kanan bawah
for(int i=x+1;i<x+14;i++){
gotoxy(i,y);cout<<char(196);
}
gotoxy(x+pos,y-1);cout<<nama;

}
void main (){

antrian z;
char x[10],y[15],w[10],pil;
textcolor(GREEN);
menu:
clrscr();
gotoxy(1,9);z.baca();
z.menu();
gotoxy(73,16);pil=getche();
switch (pil){
case ’1′ :{
textcolor(123);
gotoxy(58,23);cprintf(“<INPUT DATA>\n”);
textcolor(123);
gotoxy(54,25);cprintf(“NoUrut      :”);
cin.getline(x,sizeof(x));
textcolor(123);
gotoxy(54,27);cprintf(“Nama        :”);
cin.getline(y,sizeof(y));
textcolor(123);
gotoxy(54,29);cprintf(“Kategori L/P:”);
cin.getline(w,sizeof(w));
z.buatData(x,y,w);
goto menu;
}
case ’2′ :{z.deletekiri();
goto menu;
break;
}
case ’3′ :{z.deletekiril();
goto menu;
break;}
case ’0′ :gotoxy(46,13); cout<<”SIMULASI SELESAI”;break;
default  :{ gotoxy(46,13);cout<<”MAAF PERINTAH ANDA SALAH\n”;
goto menu;
}
}

}

  1. Belum ada trackback.

Anda harus masuk untuk mengirim sebuah komentar.
Ikuti

Get every new post delivered to your Inbox.