Uygulama-1
- M. Kasım Sular
- September 29, 2020
- 816 Görüntülenme
- 0 Yorum

Şu ana kadar işlediğimiz tüm konuları içeren bir uygulamadır.,
import java.util.ArrayList;
import javax.swing.JOptionPane;
public class OgrenciKayit {
ArrayList ogrenciler = new ArrayList<>();
public static void main(String[] args) {
OgrenciKayit a = new OgrenciKayit();
a.baslat();
}
private void baslat() {
menu();
}
private void menu() {
String str = "";
str += "Yapmak istediğiniz İşlem\n";
str += "*****************\n\n";
str += "[ 0 veya Esc] Çıkış\n";
str += "[ 1 ] Kayıt Ekle\n";
str += "[ 2 ] Kayıt Sil\n";
str += "[ 3 ] Kayıt Listele\n";
String secim = JOptionPane.showInputDialog(null, str);
if (secim == null) {
secim = "0";
} else if (secim.equals("") || secim.matches("[^0-9]+")) {
this.menu();
}
int secimSayi = Integer.parseInt(secim);
switch (secimSayi) {
case 0:
cikis();
break;
case 1:
ekle();
break;
case 2:
sil();
break;
case 3:
listele();
break;
default:
JOptionPane.showMessageDialog(null, "0-3 Arasında Bir Seçim Yapınız");
this.menu();
break;
}
}
private void listele() {
String mesaj = "";
mesaj += "Öğrenci Listesi\n";
mesaj += "*****************\n\n";
for (Object object : ogrenciler) {
mesaj += object + "\n";
}
mesaj += "";
JOptionPane.showMessageDialog(null, mesaj);
this.menu();
}
private void sil() {
String ogrenci = JOptionPane.showInputDialog(null, "Öğrenci Adı");
if (ogrenciler.contains(ogrenci)) {
ogrenciler.remove(ogrenci);
JOptionPane.showMessageDialog(null, "Silindi!");
} else {
JOptionPane.showMessageDialog(null, "Öğrenci Bulunamadı!");
}
this.menu();
}
private void ekle() {
String ogrenci = JOptionPane.showInputDialog(null, "Öğrenci Adı");
if (!ogrenciler.contains(ogrenci)) {
ogrenciler.add(ogrenci);
JOptionPane.showMessageDialog(null, "Kaydedildi!");
} else {
JOptionPane.showMessageDialog(null, "Bu Öğrenci Sistemde Kayıtlıdır!");
}
this.menu();
}
private void cikis() {
int secim = JOptionPane.showConfirmDialog(null, "Çıkmak istediğinizden Emin misiniz?");
if (secim == 0) {
System.exit(0);
} else {
this.menu();
}
}
}
+
Yorum Bırak