15/8/2007 - Telefon Simulasyonu

SELAMLAR ARKADAŞLAR...
JAVA DA GİRİŞİ KENDİ YAZDIĞIM VE PROGRAMLAMA.COM SİTESİNDE DE YAYINLANAN "TELEFON SİMÜLASYONU" İLE YAPMAK İSTİYORUM.ECLIPSE 3.2 İLE PROGRAMLANAN PROGRAMIN AMACI GAYET BASİT.TELEFON İLE(KONSOLDAN) BİR ARAMA GERÇEKLEŞTİRİLİR , ARAMA ANINDA EĞER HAT DOLUYSA TEKRAR DENENMESİ İSTENİR , BU ARADA ARAMA YAPILMASI İÇİN DE ALAN KODLARI VERİLİR(GENE KONSOLDA) İYİ EĞLENCELER... NOT:alan kodlarını MyText.txt dosyası şeklinde oluşturduğunuz paketin içine ( bu programda telephone paketi içine kaydedilmiştir. ) kaydediniz . Aynı paket içerisinde User.txt dosyası programın kendisi tarafıdan oluşturulmakta ve bu dosya daha sonra okutulmaktadır. alan kodlarını http://tr.wikipedia.org/wiki/%C4%B0l_alan_kodu adresinden bulabilirsiniz . İyi çalışmalar
//CallControl.java //KAYWINSOFT package telephone; import javax.swing.*; public class CallControl { boolean checkAvailability() { JOptionPane.showMessageDialog(null,"Telephone Numbers Simulation","KAYWINSOFT", JOptionPane.INFORMATION_MESSAGE); double random = 0; for(int i = 0; i<10 ; i++) random = 5 + Math.random() * 100;
return random>5?true:false; }
void areaCodeCheckList() { JOptionPane.showMessageDialog(null,"Telephone Numbers Simulation","KAYWINSOFT", JOptionPane.INFORMATION_MESSAGE); FileInput info = new FileInput(); info.areaCode();
}
void getting(String number) { FileInput info = new FileInput(); info.getNumber(number); }
void showing() { FileInput info = new FileInput(); info.showNumber(); }
} //FileInput.java //KAYWINSOFT package telephone;
/** * This program reads a text file line by line and print to the console. It uses * FileOutputStream to read the file. * */ import java.io.*;
public class FileInput extends CallControl {
public void areaCode(){ try { BufferedReader in; in = new BufferedReader(new FileReader("telephoneAreaCode.txt")); // dosya bir stream halinde alınır String str; // döngü içerisinde satır satır okunur. while ((str = in.readLine()) != null) System.out.println(str); // başta açılan stream kapatılır in.close();} catch (IOException e){ System.out.println("Hata oluştu."); } }//end areaCode public void getNumber(String number) { try { FileWriter yaz; yaz = new FileWriter("telephoneUser.txt"); PrintWriter okut; okut = new PrintWriter(yaz); okut.write(number); yaz.close(); }//end try catch(IOException e) { System.out.println("An error has occured"); }//end catch
}//end getNumber public void showNumber() { try { BufferedReader yaz; yaz = new BufferedReader(new FileReader("telephoneUser.txt")); String str; // döngü içerisinde satır satır okunur. while ((str = yaz.readLine()) != null) System.out.println(str); // başta açılan stream kapatılır yaz.close();} catch (IOException e){ System.out.println("Hata oluştu."); }
}//end showNumber
}//end class FileInput
//TelephoneTest.java //KAYWINSOFT package telephone;
import javax.swing.*; public class TelephoneTest {
public static void main(String[] args) { // TODO Auto-generated method stub String gets;
CallControl sub = new CallControl(); boolean checks;
checks = sub.checkAvailability();
if(checks){ sub.areaCodeCheckList(); gets = JOptionPane.showInputDialog("Please Enter the phone number");
sub.getting(gets); sub.showing();
}//end if else { System.out.println("The server is unavaiable , Please try again later"); System.exit(0); }//end else
}//end main
} /*3 farkli dosyadan olusan program dosya okuma ve yazma mantigi , paket mantigi ustune egilmesiyle birlikte OOP e giris yapan ve kendini JAVA2SSE de gelistirmek isteyenlere bir on bilgi mahiyetinde de iletilebilir.Yorumlariniz icin simdiden tesekkurler. NOT:Bu konularla ilgili her türlü soruyu gizli msj olarak iletebilirsiniz ayrica kaywinsoft_km@yahoo.com adresim de sizin sorulariniz icindir , esirgemeyiniz , kolay gelsin*/
TÜM HAKLARI BANA AİTTİR , ANLAYIŞINIZ İÇİN TEŞEKKÜR EDERİM...
|