Rabu, 28 Maret 2012

LA Pascal III

Contoh Program Case
 
uses crt;
label menu;
var i,j,n,pil : integer;
    kota : string;
procedure jalan_kanan;
begin
clrscr;
     for i :=1 to 70 do
     begin
         gotoxy (i,1);
         write(kota);
         textcolor(7);
         delay(50);
     end;
end;
procedure jalan_kiri;
begin
clrscr;     for i :=70 downto 1 do
     begin
         gotoxy (i,1);
         write(kota);
         textcolor(7);
         delay(50);
     end;
end;
procedure jalan_bawah;
begin
     for i :=1 to 25 do
     begin
     gotoxy(70,i);
     write(kota);
     textcolor(7);
     delay(50);
     end;
end;
procedure jalan_atas;
begin
     for i :=25 downto 1 do
     begin
     gotoxy(70,i);
     write(kota);
     textcolor(7);
     delay(50);
     end;
end;
procedure jalan_putar;
begin
     for i :=1 to 70 do
       begin
         gotoxy (i,1);
         write(kota);
         textcolor(7);
         delay(50);
       end;
     for i :=1 to 25 do
       begin
         gotoxy(70,i);
         write(kota);
         textcolor(7);
         delay(50);
       end;
     for i :=70 downto 1 do
       begin
         gotoxy (i,25);
         write(kota);
         textcolor(7);
         delay(50);
       end;
     for i :=25 downto 1 do
     begin
     gotoxy(1,i);
     write(kota);
     textcolor(7);
     delay(50);
     end;gotoxy(7,40);
end;
procedure input_kota;
begin
     write('Masukan kota : '); readln(kota);
     clrscr;
end;
begin
     menu:
     textbackground(0);
     clrscr;
     gotoxy(1,1); writeln('===MENU===');
     gotoxy(1,2); writeln('1. Animasi jalan Kanan');
     gotoxy(1,3); writeln('2. Animasi jalan Bawah');
     gotoxy(1,4); writeln('3. Animasi jalan Atas');
     gotoxy(1,5); writeln('4. Animasi jalan Kiri');
     gotoxy(1,6); writeln('5. Animasi jalan Putar');
     gotoxy(1,7); writeln('6. Exit');
     gotoxy(1,9); write('Masukan pilihan : ');readln(pil);
case pil of
1: begin
  clrscr;
  gotoxy(1,1);input_kota;
  jalan_kanan;
  gotoxy(10,20); write('Animasi selesai');
  readln;
  goto menu;
  end;
2:begin
  clrscr;
  gotoxy(1,1);input_kota;
  jalan_bawah;
  gotoxy(10,20);writeln('Animasi selesai');
  readln;
  goto menu;
  end;
3: begin
  clrscr;
  gotoxy(1,1);input_kota;
  jalan_atas;
  gotoxy(10,20); writeln('Animasi selesai');
  readln;
  goto menu;
  end;
4: begin
  clrscr;
  gotoxy(1,1);input_kota;
  jalan_kiri;
  gotoxy(10,20); writeln('Animasi selesai');
  readln;
  goto menu;
  end;
5: begin
  clrscr;
  gotoxy(1,1);input_kota;
  jalan_putar;
  gotoxy(50,60); writeln('Animasi selesai');
  readln;
  goto menu;
  end;
6: begin
   clrscr;
   gotoxy(10,40);writeln('Bye');
   readln;
   end;
   else
begin
     gotoxy(19,9);write('Pilihan Salah');
readln; goto menu;
end;
end;
clrscr;
readln;
end.

Output :

0 komentar:

Posting Komentar

 
;