1. Dalam pembuatan program ini, kami selaku pembuat program menggunakan 3 library yaitu
iostream, string.h, fstream. Dengan script sebagai berikut :
#include <iostream>
#include <string.h>
#include <fstream>
2. Lalu kami dalam membuat program ini memakai prosedur, tujuannya adalah untuk
memecah program yang rumit dan besar menjadi program-program yang lebih sederhana
atau kecil sehingga program yang kami buat menjadi lebih singkat, mempersingkat waktu
pengerjaan program, dan apabila terdapat kesalahan pada program maka akan cepat
terselesaikan. Script prosedur yang kami buat pada program ini yaitu sebagai berikut :
struct data{
char ttss[100];
char tts1[100];
};
data tts[10];
if (k==1){
//jawaban teka teki silang;
strcpy(tts[1].tts1,"jabum");
strcpy(tts[2].tts1,"sabuga");
strcpy(tts[3].tts1,"mektan");
strcpy(tts[4].tts1,"fitb");
strcpy(tts[5].tts1,"latman");
strcpy(tts[6].tts1,"kalkulus");
strcpy(tts[7].tts1,"santet");
strcpy(tts[8].tts1,"ganas");
strcpy(tts[9].tts1,"chempro");
strcpy(tts[10].tts1,"rbl");
// bentuk TTS
strcpy(tts[1].ttss," 1[][][][][]");
strcpy(tts[2].ttss," 2[][][][][][]");
strcpy(tts[3].ttss," 3[][][][][][]");
strcpy(tts[4].ttss," 4[][][][]");
strcpy(tts[5].ttss," 5[][][][][]");
strcpy(tts[6].ttss," 6[][][][][][][][]");
strcpy(tts[7].ttss," 7[][][][][][]");
strcpy(tts[8].ttss," 8[][][][][]");
strcpy(tts[9].ttss," 9[][][][][][]");
strcpy(tts[10].ttss," 10[][][]");
for (i=1;i<jumlah+1;i++){
cout << "Masukan nama pemain ke- "<< i <<" : ";
cin >> nama;
while (j<11){
cout << "Pertanyaan yang ingin dijawab: ";
cin >> no;
cout << "Masukan jawaban: ";
cin >> a;
if (strcmp(a,tts[no].tts1)==0){
nilai=nilai+1;
if (no==1){
strcpy(tts[1].ttss," J A B U M ");
}
else if (no==2){
strcpy(tts[2].ttss," S A B U G A");
}
else if (no==3){
strcpy(tts[3].ttss," M E K T A N");
}
else if (no==4){
strcpy(tts[4].ttss," F I T B");
}
else if (no==5){
strcpy(tts[5].ttss," L A T M A N");
}
else if (no==6){
strcpy(tts[6].ttss," K A L K U L U S");
}
else if (no==7){
strcpy(tts[7].ttss," S A N T E T");
}
else if (no==8){
strcpy(tts[8].ttss," G A N A S");
}
else if (no==9){
strcpy(tts[9].ttss," C H E M P R O");
}
else if (no==10){
strcpy(tts[10].ttss," R B L");
}
}
for (m=0;m<11;m++){
cout << tts[m].ttss << "\n";
}
j++;
}
cout << "\n point anda sebesar: " << nilai << "\n";
filenilai << "point player ke- "<< i << " sebesar: "<<nilai <<"\n";
strcpy(tts[1].ttss," 1[][][][][]");
strcpy(tts[2].ttss," 2[][][][][][]");
strcpy(tts[3].ttss," 3[][][][][][]");
strcpy(tts[4].ttss," 4[][][][]");
strcpy(tts[5].ttss," 5[][][][][]");
strcpy(tts[6].ttss," 6[][][][][][][][]");
strcpy(tts[7].ttss," 7[][][][][][]");
strcpy(tts[8].ttss," 8[][][][][]");
strcpy(tts[9].ttss," 9[][][][][][]");
strcpy(tts[10].ttss," 10[][][]");
nilai = 0;
j=1;
}
}
else if (k==2){
//jawaban teka teki silang;
strcpy(tts[1].tts1,"chaos");
strcpy(tts[2].tts1,"inisiasi");
strcpy(tts[3].tts1,"interfak");
strcpy(tts[4].tts1,"debust");
strcpy(tts[5].tts1,"sbm");
strcpy(tts[6].tts1,"donor");
strcpy(tts[7].tts1,"intel");
// bentuk TTS
strcpy(tts[1].ttss," 1[][][][][]");
strcpy(tts[2].ttss," 2[][][][][][][][]");
strcpy(tts[3].ttss," 3[][][][][][][][]");
strcpy(tts[4].ttss," 4[][][][][][]");
strcpy(tts[5].ttss," 5[][][]");
strcpy(tts[6].ttss," 6[][][][][]");
strcpy(tts[7].ttss," 7[][][][][]");
for (i=1;i<jumlah+1;i++){
cout << "Masukan nama pemain ke- "<< i <<" : ";
cin >> nama;
while (j<8){
cout << "Pertanyaan yang ingin dijawab: ";
cin >> no;
cout << "Masukan jawaban: ";
cin >> a;
if (strcmp(a,tts[no].tts1)==0){
nilai=nilai+1;
if (no==1){
strcpy(tts[1].ttss," C H A O S ");
}
else if (no==2){
strcpy(tts[2].ttss," I N I S I A S I ");
}
else if (no==3){
strcpy(tts[3].ttss," I N T E R F A K ");
}
else if (no==4){
strcpy(tts[4].ttss," D E B U S T ");
}
else if (no==5){
strcpy(tts[5].ttss," S B M");
}
else if (no==6){
strcpy(tts[6].ttss," D O N O R ");
}
else if (no==7){
strcpy(tts[7].ttss," I N T E L ");
}
}
for (m=0;m<8;m++){
cout << tts[m].ttss << "\n";
}
j++;
}
cout << "\n Point anda sebesar: " << nilai << "\n";
cout << endl;
filenilai << "point player ke- "<< i << " sebesar: "<<nilai <<"\n";
strcpy(tts[1].ttss," 1[][][][][]");
strcpy(tts[2].ttss," 2[][][][][][][][]");
strcpy(tts[3].ttss," 3[][][][][][][][]");
strcpy(tts[4].ttss," 4[][][][][][]");
strcpy(tts[5].ttss," 5[][][]");
strcpy(tts[6].ttss," 6[][][][][]");
strcpy(tts[7].ttss," 7[][][][][]");
nilai = 0;
j=1;
}
}
else if (k == 3){
//jawaban teka teki silang;
strcpy(tts[1].tts1,"snapgram");
strcpy(tts[2].tts1,"apatis");
strcpy(tts[3].tts1,"bengkok");
strcpy(tts[4].tts1,"nikerun");
strcpy(tts[5].tts1,"kidas");
strcpy(tts[6].tts1,"sith-r");
strcpy(tts[7].tts1,"sabtu");
// bentuk TTS
strcpy(tts[1].ttss," 1[][][][][][][][]");
strcpy(tts[2].ttss," 2[][][][][][]");
strcpy(tts[3].ttss," 3[][][][][][][]");
strcpy(tts[4].ttss," 4[][][][][][][]");
strcpy(tts[5].ttss," 5[][][][][]");
strcpy(tts[6].ttss," 6[][][][][][]");
strcpy(tts[7].ttss," 7[][][][][]");
for (i=1;i<jumlah+1;i++){
cout << "Masukan nama pemain ke- "<< i <<" : ";
cin >> nama;
while (j<8){
cout << "Pertanyaan yang ingin dijawab: ";
cin >> no;
cout << "Masukan jawaban: ";
cin >> a;
if (strcmp(a,tts[no].tts1)==0){
nilai=nilai+1;
if (no==1){
strcpy(tts[1].ttss," S N A P G R A M ");
}
else if (no==2){
strcpy(tts[2].ttss," A P A T I S ");
}
else if (no==3){
strcpy(tts[3].ttss," B E N G K O K ");
}
else if (no==4){
strcpy(tts[4].ttss," N I K E R U N ");
}
else if (no==5){
strcpy(tts[5].ttss," K I D A S ");
}
else if (no==6){
strcpy(tts[6].ttss," S I T H - R ");
}
else if (no==7){
strcpy(tts[7].ttss," S A B T U ");
}
}
for (m=0;m<8;m++){
cout << tts[m].ttss << "\n";
}
j++;
}
cout << "\n Point anda sebesar: " << nilai << "\n";
cout << endl;
filenilai << "point player ke- "<< i << " sebesar: "<<nilai <<"\n";
strcpy(tts[1].ttss," 1[][][][][][][][]");
strcpy(tts[2].ttss," 2[][][][][][]");
strcpy(tts[3].ttss," 3[][][][][][][]");
strcpy(tts[4].ttss," 4[][][][][][][]");
strcpy(tts[5].ttss," 5[][][][][]");
strcpy(tts[6].ttss," 6[][][][][][]");
strcpy(tts[7].ttss," 7[][][][][]");
nilai = 0;
j=1;
}
}
}
3. Setelah script prosedur telah selesai kami buat, lalu kami membuat algoritma program
utama. Kami medeklarasikan variabel lvl, dan lagi dengan tipe data integer. Lalu kami
membuat file external yang bernama filenilai untuk program yang kami buat. Lalu pada
program c++ file external tersebut dibuka untuk melihat nilai pemain. Scriptnya adalah
sebagai berikut
int main() {
int lvl,lagi;
ofstream filenilai;
filenilai.open ("hasil.txt", ios::trunc);
4. Lalu pada program yang kami buat kami ingin menampilkan kata – kata “TEKA TEKI
SILANG TPB VERSION “ dengan script sebagai berikut
cout << " TEKA TEKI SILANG \n";
cout << " TPB VERSION \n";
cout << "--------------------------------\n";
5. selanjutnya, di program utama kami membuat program pengulangan/ looping dengan
menggunakan fungsi while, dengan menginisialisasi lagi == 1. Didalam fungsi looping
while kami menampilkan pilihan level games, lalu input pilihan level dengan scriptny
sebagai berikut
lagi = 1;
while (lagi ==1){
if (lvl ==1){
level(lvl);
}
else if (lvl ==2){
level(lvl);
}
else if (lvl ==3){
level(lvl);
}
7. Langkah selanjutnya, setelah membuat fungsi percabangan, pada program yang kami buat
kami membuat pilihan apabila games sudah berakhir, pemakai akan memilih ingin
melanjutkan permainan atau tidak dengan script sebagai berikut
filenilai.close();
return 0;
}