Bunun Burada Ne İşi Var?
Dün şehre inmek için Sayın Menderes Türel’in zamanında Hafif Metro ...
Başlık da maşallah Melekler & Şeytanlar gibi oldu, neyse.
Nesneye Dayalı Programlama dersinin ilk ödevini bu hafta teslim ettik. Bizden basit bir restoran yönetim sistemi yazmamız istendi. Tabii ki nesneleri, nesneler arası kalıtım (inheritance), çok şekillilik (polymorphism), arayüzler (interface) kullanarak!
Proje JAVA’da geliştirildi. Takım halinde, üç kişi geliştirdik. Bazılarımız NetBeans kullandı, bazılarımız Eclipse. Bazılarımız ise Windows 7’de Eclipse’i bir türlü çalıştıramayıp Windows XP sanal makinesi kurdu. (Ben)
EK1: Eclipse’i Windows 7′de çalıştıramama nedenim şuymuş: Ben Windows 7′yi 64 bit kurmuştum. Ancak Eclipse 32 bit bir uygulama olduğundan JDK 64-bit’in yanına, 32-bit JDK da yüklemek gerekiyormuş. Yükledim, kurtuldum.
Projede nesneler arası iletişim, kalıtım ve çok şekilliliğe örnek bulabilirsiniz. Program ayrıca 1.5 sürpriz yumurta içeriyor, belki onları da bulabilirsiniz.
Programda üç tip kullanıcı için üç senaryo var: Yönetici, restoran ve kullanıcı ekleyip çıkartabiliyor. Restoran operatörü kullanıcının verdiği siparişleri onaylayıp kurye ile gönderiyor, yemek ve menü ekliyor. Müşteri ise sipariş veriyor.
Projenin kolay kontrolü için roller arası geçişi tek butona indirgedik. Ama normalde herkes kullanıcı adı ve şifresiyle girebilir. (User sınıfına User ve Pass eklenmesi yeterli olacaktır.)
Projenin kaynak kodlarını ve raporunu takım arkadaşlarım Gül Deliorman ve Özlem Gürses’in de onaylarını alarak burada paylaşıyorum.
Kaynak kodlarına bilgisayarınıza indirmeden göz atmak isterseniz yazının devamına bakabilirsiniz. Paketlerin ve sınıfların ne işe yaradığını proje raporunda bulabilirsiniz.
Herkese iyi günler.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | package proje.bootstrapper; import proje.restaurant.Restaurant; import proje.ui.Entry; import proje.user.Administrator; import proje.user.User; import proje.util.SortableList; public class Main { /* En Geniş İçerikli Kolleksiyonlar */ public static final SortableList<User> users = new SortableList<User>(); public static final SortableList<Restaurant> restaurants = new SortableList<Restaurant>(); public static void main(String[] args) { /* İnit */ System.out.println(" Çökmez Bilişim Restoran Sistemleri Gururla Sunar" ); System.out.println("------------------------------------------------------"); System.out.println("05-06-7670 Umut BENZER http://www.ubenzer.com/"); System.out.println("05-0607699 Gül DELİORMAN http://www.guldeliorman.com/"); System.out.println("05-07-8496 Özlem GÜRSES null nıl nul zört zırt bırt"); System.out.println("------------------------------------------------------"); /* Projenin rahat kontrolü için rastgele bilgiler eklenir. */ new Administrator("Fred","Çakmaktaş"); PlaceHolder.addRandomCustomer(250); PlaceHolder.addRandomRestaurant(50); for(Restaurant r: restaurants) { PlaceHolder.addRandomYemek(r, (int)(Math.random() * 25) + 1); PlaceHolder.addRandomMenu(r, (int)(Math.random() * 40) + 1); } PlaceHolder.generateRandomOrder(1000); /* Arayüzü Göster */ Entry e=new Entry(); e.setVisible(true); } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 | package proje.bootstrapper; import java.util.Date; import java.util.Vector; import proje.restaurant.Menu; import proje.restaurant.Order; import proje.restaurant.Restaurant; import proje.restaurant.Yemek; import proje.user.Customer; import proje.user.Operator; import proje.user.User; import proje.util.CONSTANT; public class PlaceHolder { @SuppressWarnings({ "deprecation", "unchecked" }) public static void generateRandomOrder(int orderCount){ System.out.println("Rastgele sipariş yaratılıyor. Bu işlem biraz zaman alabilir..."); Vector yemekVeMenuler= new Vector();//Rastgele seçilen Restoranın içinden rastgele seçilen yemek ve menülerin tutulacağı vektör Vector<String> yorumlar=new Vector<String>(); yorumlar.add("Hayatımda yediğim en güzel yemekti."); yorumlar.add("Mmm nefiss..."); yorumlar.add("Pardon tarifini alma şansım var mı acaba?"); yorumlar.add("Evde denedim olmadı, neyi eksik yaptım acaba..."); yorumlar.add("Ben size acı sos da ekleyin dedim acı sos macı sos yoktu ne biçim servis bu!"); yorumlar.add("Sizin yüzünüzden obez olacağım ne leziz yemekti öyle!"); yorumlar.add("Kaç kere tembih ettiğim halde her seferinde salça da koyuyorsunuz artık sizden yiyecek almayacağım"); yorumlar.add("Beşamel sos dışındakileri beğendim, tavsiye ederim."); yorumlar.add("Kendime sormak zorunda kaldım acaba Kanada'da mı yaşıyorum diye... Çok yavaş servisti."); yorumlar.add("Van münüt, daha da yemem."); yorumlar.add("Aşçını da al git üleyn!"); yorumlar.add("Aşçılık yan gelip yatma yeri değildir."); yorumlar.add("Tek kelimeyle nefisti !"); User u; Customer c; Order o; int orderStatusVariable,vote,voteNumber; Date orderDate; Date deliverDate; while(orderCount>0){ do{//rastgele müşteri seçilir u=Main.users.elementAt( (int)(Math.random()*(Main.users.size())) ); }while(!(u instanceof Customer)); c=(Customer)u; Restaurant r=Main.restaurants.elementAt((int)(Math.random()*(Main.restaurants.size())));//rastgele restoran seçilir yemekVeMenuler.add(r.getMenuler().elementAt((int)(Math.random()*(r.getMenuler().size())))); yemekVeMenuler.add(r.getYemekler().elementAt((int)(Math.random()*(r.getYemekler().size())))); o = new Order(c,r,yemekVeMenuler); orderStatusVariable = (int)(Math.random() * 10); orderDate = new Date(); orderDate.setMonth((int)(Math.random()*11)+1); orderDate.setDate((int)(Math.random()*30)+1); orderDate.setHours((int)(Math.random()*59)+1); orderDate.setMinutes((int)(Math.random()*59)+1); orderDate.setSeconds((int)(Math.random()*59)+1); o.setOrderTime(orderDate); switch(orderStatusVariable){ case 1: //Sipariş yolda o.setOrderInProgress(); break; case 2: case 3: case 4: case 5: case 6: case 7://Sipariş iletildi o.setOrderDelivered(); deliverDate =new Date(); deliverDate.setYear(2009); do{ deliverDate.setMonth(((int)(Math.random()*11)+1)); deliverDate.setDate((int)(Math.random()*30)+1); deliverDate.setHours((int)(Math.random()*59)+1); deliverDate.setMinutes((int)(Math.random()*59)+1); deliverDate.setSeconds((int)(Math.random()*59)+1); }while(deliverDate.getMonth() < orderDate.getMonth() || deliverDate.getDate()<orderDate.getDate() || deliverDate.getHours()<orderDate.getHours() || deliverDate.getMinutes()<orderDate.getMinutes() || deliverDate.getSeconds()<orderDate.getSeconds()); o.setCompleteTime(deliverDate); voteNumber=((int)(Math.random()*10)); if (voteNumber > 4) { vote=(int)(Math.random()*5); o.voteForHiz(vote); } voteNumber=((int)(Math.random()*10)); if (voteNumber > 4) { vote=(int)(Math.random()*5); o.voteForLezzet(vote); } voteNumber=((int)(Math.random()*10)); if (voteNumber > 4) { vote=(int)(Math.random()*4); o.voteForFiyat(vote); } if(((int)(Math.random()*2))==0){ o.setComment(yorumlar.elementAt((int)(Math.random()*yorumlar.size()))); } break; } orderCount--; } System.out.println("Yaratıldı."); } public static void addRandomMenu(Restaurant r, int number) { Vector<String> v = new Vector<String>(); v.add("Big King XXL"); v.add("Big King"); v.add("Büyük Menü"); v.add("Akıllı Seçim"); v.add("Ekonomik Seçim"); v.add("Diyet Seçim"); v.add("Şefin Önerisi"); v.add("Günün Mönüsü"); v.add("Amerikan Seçim"); v.add("Türk Özel"); v.add("Hafif Akşam Yemeği"); v.add("Günün Menüsü"); v.add("Şeften Seçmeler"); v.add("İngiliz Usülü"); v.add("Enerjik Menü"); v.add("Tatlı Severler İçin Özel Menü"); v.add("Yeni Menü"); if (number > v.size()) { number = v.size(); } while(number > 0) { /* Menü içeriğini hazırla */ Vector<Yemek> menuYemek = new Vector<Yemek>(); for(int i = 0; i <= (int)(Math.random() * 4) + 1; i++) { menuYemek.add(r.getYemekler().elementAt((int)(Math.random() * r.getYemekler().size()))); } int indis = (int)(Math.random() * number); String y = v.elementAt(indis); double f = (double)((int)(Math.random() * 23) + 0.99); r.addMenu(new Menu(y,f,menuYemek)); v.removeElementAt(indis); number--; } } public static void addRandomYemek(Restaurant r, int number) { Vector<String> v = new Vector<String>(); v.add("İskender döner"); v.add("Domates çorbası"); v.add("İmam Bayıldı"); v.add("Mevsim Salatası"); v.add("Tavuk ızgara"); v.add("Çöp şiş"); v.add("Kumpir"); v.add("Kola"); v.add("Suşi"); v.add("Pizza"); v.add("Ekşili Ördek Çorbası"); v.add("Ahtapot Kavurma"); v.add("Zeytin Sosuna Bulanmış Feta"); v.add("Yayık ayranı"); v.add("Buzlu çay"); v.add("Çiğ Börek"); v.add("Efsanevi Salçalı Kumru"); v.add("Kutu ayran"); v.add("Supangle"); v.add("Keşkül"); v.add("Helva"); v.add("Enginar Yaprağına Yatırılmış Pekin Ördeği"); v.add("Portakallı Ördek"); v.add("Cacık"); v.add("Şefin Sürprizi"); v.add("Yoğurt"); v.add("Günün Çorbası"); v.add("Patates Kızartması"); v.add("Hamburger"); if (number > v.size()) { number = v.size(); } while(number > 0) { int indis = (int)(Math.random() * number); String y = v.elementAt(indis); double f = (double)((int)(Math.random() * 23) + 0.99); r.addYemek(new Yemek(y,f)); v.removeElementAt(indis); number--; } } public static String generateRandomLastName() { String soyad[] = {"benzer", "kayalı", "gürses", "yaşar", "avşar","ürek","ergen","tayfur","tuğba", "alkan", "anık","sert","andıç","yılmaz","şahin","kurt","çelik", "boya","hüyük","güler","sever","ceylan"}; /* * "" sayısının fazla olması, daha az ek seçilmesini sağlamaya * yöneliktir. */ String ekleOnSoyad[] = {"öz","has","","","","","","","","","","",""}; String ekleArkaSoyad[] = {"oğlu", "gil", "oğulları","","","","","","","","","",""}; return ekleOnSoyad[(int) (Math.random() * ekleOnSoyad.length)] .concat(soyad[(int) (Math.random() * soyad.length)] .concat(ekleArkaSoyad[(int) (Math.random() * ekleArkaSoyad.length)])); } public static String generateRandomName(boolean careGender, boolean gender) { /* Bu kod parçası daha önce Bilmuh 2. Sınıfta insanları sınıflara dağıtma ödevinde kullanılmıştır. */ String bayAd[] = {"umut", "hüseyin","hüsnü","şevki","muharrem","haydar","ajdar","ferdi","fatih","mehmet","hüsnü","okan","metin","okşan"}; String bayanAd[] = {"didem", "narin","özlem","fatma","ayşe","hülya","gülben","ahu","tuğba","banu","ayşe","canan", "yeliz","yeşim","gülşen","gizem","saniye","nazlı"}; /* * "" sayısının fazla olması, daha az ek seçilmesini sağlamaya * yöneliktir. */ String ekleOnAd[] = {"bir", "","","","","","","",""}; String ekleArkaAd[] = { "can", "gül", "nur", "su", "","","","","","","",""}; int rndgend = (int) (Math.random() * 2); if (!careGender) { return ekleOnAd[(int) (Math.random() * ekleOnAd.length)].concat( (rndgend == 1 ? bayanAd[(int) (Math.random() * bayanAd.length)] .concat(ekleArkaAd[(int) (Math.random() * ekleArkaAd.length)]) : bayAd[(int) (Math.random() * bayAd.length)] .concat(ekleArkaAd[(int) (Math.random() * ekleArkaAd.length)]))); } else { return ekleOnAd[(int) (Math.random() * ekleOnAd.length)].concat( (gender == CONSTANT.FEMALE ? bayanAd[(int) (Math.random() * bayanAd.length)] .concat(ekleArkaAd[(int) (Math.random() * ekleArkaAd.length)]) : bayAd[(int) (Math.random() * bayAd.length)] .concat(ekleArkaAd[(int) (Math.random() * ekleArkaAd.length)]))); } } public static String generateRandomAdress() { String sehirler[] = {"ANKARA","ANTALYA","İZMİR","İSTANBUL","MANİSA"}; String yollar[] = {"Kemeraltı Caddesi","İnciraltı Caddesi","Atatürk Caddesi","Mehmet Akif Caddesi","Ankara Asfaltı", "Antalya Dünyanın En Güzel Şehridir Caddesi","Zeki Müren Sokak","Altıncı Cadde","Kıbrıs Şehitleri Caddesi", "Düden Caddesi","Konur Sokak","Kafanfil Sokak","Meşrutiyet Caddesi","Konyaaltı Caddesi","<<>>"}; String yapilar[] = {"Yıkılmaz Apartmanı","Cingöz Apartmanı","Benzer Apt.","Bobiler Apt.","Bill Gates Apt.", "Öğrenci Yurtları","ESHOT Şube Müdürlüğü","Akman Sitesi","Fevzigil Sitesi","","","","","","","","","","","","","","","","","","","","","","",""}; String mahalleler[] = {"Ulus","Işık","Üçgen","Düden","Kepezaltı","Kepezüstü","Haşim İşcan","Lara","Sanayi","Liman"}; String mahalle = mahalleler[(int) (Math.random() * mahalleler.length)].concat(" Mahallesi"); String yol = yollar[(int) (Math.random() * yollar.length)]; if (yol.equals("<<>>")) { if ((int) (Math.random() * 2) < 1) { yol = (int) (Math.random() * 10000) + ". Sokak"; } else { yol = (int) (Math.random() * 150) + ". Cadde"; } } String apt = yapilar[(int) (Math.random() * yapilar.length)]; if (!(apt.equals(""))) { apt.concat(" "); } return mahalle + " " + yol + " " + apt + "No:" + ((int) (Math.random() * 70) + 1) + " Daire: " + (int) ((Math.random() * 15) + 1) + " " + sehirler[(int) (Math.random() * sehirler.length)]; } public static void addRandomCustomer(int number) { for (int i = 0; i < number; i++) { int gender = (int) (Math.random() * 2); Customer Musteri = new Customer(PlaceHolder.generateRandomName(true, (gender == 1 ? CONSTANT.FEMALE : CONSTANT.MALE)), PlaceHolder.generateRandomLastName(), PlaceHolder.generateRandomAdress(), (gender == 1 ? CONSTANT.FEMALE : CONSTANT.MALE), "standart insan tipi"); int tipDegisimi= (int)(Math.random()*5); switch(tipDegisimi){ case 4: int newType = (int)(Math.random()*3); switch (newType) { case 0: newType = CONSTANT.SILVERCUSTOMER; break; case 1: newType = CONSTANT.GOLDCUSTOMER; break; case 2: newType = CONSTANT.URANIUMCUSTOMER; break; } Musteri.changeType(newType); } System.out.println(Musteri); } } public static void addRandomRestaurant(int number) { String ad[] = {"kemeraltı", "ışıklar","dokuma","kepez","sahil","","hasanlar","kırık çatal"}; String sonad[] = {"pidecisi", "kepabçısı", "light ürünleri a.ş.", "gıda", "kokoreççisi", "köftecisi", "balık pişiricisi","suşicisi","çin lokantaları zinciri","simitçisi","la foodé","simit evi"}; String ekleOnAd[] = {"öz ", "önder ","öz hakiki ","antalya ","izmir ","istanbul ","ankara","lezzette sınır tanımaz","","","","",""}; for (int i=0; i < number; i++) { String yeniIsim = ekleOnAd[(int) (Math.random() * ekleOnAd.length)].concat( ad[(int) (Math.random() * ad.length)] .concat(" ".concat(sonad[(int) (Math.random() * sonad.length)]))); Restaurant r = new Restaurant(yeniIsim,PlaceHolder.generateRandomAdress(), new Operator(generateRandomName(false,false),PlaceHolder.generateRandomLastName())); System.out.println(r); } } } |
1 2 3 4 5 | package proje.restaurant; public interface Fiyatlandirilabilir { public double getPrice(); } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | package proje.restaurant; import java.util.Vector; public class Menu implements Fiyatlandirilabilir { private Vector<Yemek> yemekleri; /* Menüdeki yemekler */ private double fiyati; /* Her yemeğin kendine ait fiyatı mavcuttur ancak menülerde özel indirim yapılması gibi bir durum söz konusu olabileceğinden eklenmiştir. */ private String name; public Menu(String name, double fiyati, Vector<Yemek> yemekListesi) { this.name = name; this.fiyati = fiyati; this.yemekleri = yemekListesi; } public Vector<Yemek> getMenuYemekleri() { return this.yemekleri; } public void setPrice(double fiyat) { this.fiyati=fiyat; } public double getPrice() { return this.fiyati; } public void yemekEkle(Yemek yeniYemek){//menüye yeni yemek eklenmesini sağlar yemekleri.add(yeniYemek); } public void addYemek(Yemek y) { this.yemekleri.add(y); } public void removeYemek(Yemek y) { this.yemekleri.remove(y); } public void setName(String name) { this.name = name; } public String getName() { return name; } @Override public String toString() { return this.name; } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 | package proje.restaurant; import java.text.DateFormat; import java.util.Date; import java.util.Vector; import proje.user.Customer; import proje.util.CONSTANT; @SuppressWarnings("unchecked") public final class Order implements Comparable, Fiyatlandirilabilir { private Customer musteri; // hangi müşteri siparis etmiş private Restaurant restoran; // Hangi restoranın siparişi private Date orderTime = null; //saat kaçta sipariş edilmiş private Date completeTime = null; /* Siparişin teslim tarihi */ private Vector yemekVeMenuler = new Vector(); // Sepetin içeriğini oluşturan Yemek ve Menu sınıfları. private double tutar = -1; private int hizOy = -1; private int lezzetOy = -1; private int fiyatOy = -1; private String comment; private int orderStatus = CONSTANT.NEWORDER; public Order(Customer c, Restaurant r, Vector orderDetails) { this.musteri = c; this.restoran = r; this.restoran.newOrder(this); this.musteri.newOrder(this); this.orderTime = new Date(); for(Object o:orderDetails) { if(o instanceof Yemek) { if(r.getYemekler().contains((Yemek)o)) { this.yemekVeMenuler.add(o); } } if(o instanceof Menu) { if(r.getMenuler().contains((Menu)o)) { this.yemekVeMenuler.add(o); } } } this.tutar = this.getPrice(); } public Vector getOrderDetails() { return yemekVeMenuler; } public String getComment() { return this.comment; } public Customer getCustomer() { return this.musteri; } public Restaurant getRestaurant() { return this.restoran; } /*** * Siparişin yeni (onaylanmamış) olup olmadığını öğrenmeyi sağlar. * * @return Sipariş yeni mi? */ public boolean isOrderNew() { return (this.getOrderStatus() == CONSTANT.NEWORDER ? true : false); } /*** * Siparişin yolda olup olmadığını öğrenmeyi sağlar. * * @return Sipariş yolda mı? */ public boolean isOrderInProgress() { return (this.getOrderStatus() == CONSTANT.ORDERINPROGRESS ? true : false); } /*** * Siparişin yerine ulaşıp ulaşmadığını öğrenmeyi sağlar. * * @return Sipariş yerine ulaştı mı? */ public boolean isOrderDelivered() { return (this.getOrderStatus() == CONSTANT.DELIVEREDORDER ? true : false); } /** * Siparişe yorum eklemeyi sağlar. Bunun için siparişin yerine ulaşmış olması gerekir. * Yorum nesneye kaydedilirse true, şartlar sağlanmıyorsa false döner. * * @param Yorum * @return Sisteme işlenip işlenmediği */ public boolean setComment(String c) { //if (this.isOrderDelivered()) { this.comment = c; return true; // } // return false; } public void setOrderTime(Date d) { this.orderTime = d; } public boolean setCompleteTime(Date d) { if (this.isOrderDelivered()) { this.completeTime = d; return true; } return false; } /** * Müşteri siparişinden vazgeçebilir. Eğer sipariş yola çıkmadıysa iptal imkanı vardır. Bu durumda * bu metot siparişi iptal eder ve true gönderir. * * Sipariş eğer yola çıktıysa artık iptal edilemez ve false gönderilir. * * @return Sipariş İptal Edildi mi */ public boolean cancelOrder () { if (isCancelable()) { this.killOrder(); return true; } else { return false; } } private boolean isCancelable() { return (this.orderStatus != CONSTANT.NEWORDER ? false : true); } public int getOrderStatus() { return this.orderStatus; } /*** * Siparişi yola çıktı olarak işaretler. Eğer sipariş zaten yoldaysa ya da ulaşmışsa bu işlem * gerçekleştirilemez ve false gönderilir. * * Bu metod sadece yeni bir siparişi yolda olarak işaretlemeye yarar. * * @return siparişDurumuDeğiştiMi */ public boolean setOrderInProgress() { if (this.orderStatus == CONSTANT.NEWORDER) { this.orderStatus = CONSTANT.ORDERINPROGRESS; return true; } return false; } /*** * Siparişi yerine ulaştı olarak işaretler. Eğer sipariş zaten yerine ulaşmışsa bu işlem * gerçekleştirilemez ve false gönderilir. * * Bu metod yeni bir siparişi ya da yolda olan bir siparişi yerine ulaştı olarak işaretler. * * @return siparişDurumuDeğiştiMi */ public boolean setOrderDelivered() { if (this.orderStatus != CONSTANT.DELIVEREDORDER) { if (this.musteri.getIsTypeCheckingAutomated() == true ) { /* Müşterinin tipini upgrade edecek miyiz? */ this.musteri.changeType(CONSTANT.SILVERCUSTOMER, true); if(this.musteri.getTotalOrderCount() >= CONSTANT.GOLDCUSTOMERLIMIT){ this.musteri.changeType(CONSTANT.GOLDCUSTOMER, true); } if (this.musteri.getTotalOrderCount() >= CONSTANT.URANIUMCUSTOMERLIMIT){ this.musteri.changeType(CONSTANT.URANIUMCUSTOMER, true); } } this.completeTime = new Date(); this.orderStatus = CONSTANT.DELIVEREDORDER; return true; } else { return false; } } public Date getOrderTime() { return this.orderTime; } /** * Siparişin yerine ulaşma tarihini döndürür. Eğer sipariş yerine ulaşmamışsa henüz * geriye null döner. * @return null || Date */ public Date getCompleteTime() { return this.completeTime; } public int compareTo (Object o) { if (!(o instanceof Order)) { throw new ClassCastException(); } return this.orderTime.compareTo(((Order)o).getOrderTime()); } /** * Siparişin hızına oy verilir. Oy verebilmek için siparişin yerine * ulaşmış olması gerekmektedir. Aksi halde metod false döndürür. * * @param 0 ile 2 arası oy. (- değerler geçersiz oy sayılır, 2'den büyük oylar 2 sayılır.) * @return oy verilirse true, oy kabul edilmezse false */ public boolean voteForHiz (int vote) { if (this.isOrderDelivered()) { if (vote < -1) { vote = -1; } if (vote > 2) { vote = 2; } this.hizOy = (vote > -1 ? ++vote : vote); return true; } return false; } /** * Siparişin lezzetine oy verilir. Oy verebilmek için siparişin yerine * ulaşmış olması gerekmektedir. Aksi halde metod false döndürür. * * @param 0 ile 2 arası oy. (- değerler geçersiz oy sayılır, 2'den büyük oylar 2 sayılır.) * @return oy verilirse true, oy kabul edilmezse false */ public boolean voteForLezzet (int vote) { if (this.isOrderDelivered()) { if (vote < -1) { vote = -1; } if (vote > 2) { vote = 2; } this.lezzetOy = (vote > -1 ? ++vote : vote); return true; } return false; } /** * Siparişin fiyatına oy verilir. Oy verebilmek için siparişin yerine * ulaşmış olması gerekmektedir. Aksi halde metod false döndürür. * * @param 0 ile 2 arası oy. (- değerler geçersiz oy sayılır, 2'den büyük oylar 2 sayılır.) * @return oy verilirse true, oy kabul edilmezse false */ public boolean voteForFiyat (int vote) { if (this.isOrderDelivered()) { if (vote < -1) { vote = -1; } if (vote > 2) { vote = 2; } this.fiyatOy = (vote > -1 ? ++vote : vote); return true; } return false; } public int getHizPuan () { return this.hizOy; } public int getLezzetPuan () { return this.lezzetOy; } public int getFiyatPuan () { return this.fiyatOy; } public double getGenelPuan () { if (!this.isUserVotedForThisOrder()) return -1; int toplam = 0; int bolum = 0; if (this.getHizPuan() != -1) { toplam += this.getHizPuan(); bolum++; } if (this.getLezzetPuan() != -1) { toplam += this.getLezzetPuan(); bolum++; } if (this.getFiyatPuan() != -1) { toplam += this.getFiyatPuan(); bolum++; } return (toplam + 0.0) / (bolum + 0.0); } /*** * Kullanıcı bu sipariş için oy kullandı mı? * * @return */ public boolean isUserVotedForThisOrder() { if (this.fiyatOy != -1 || this.lezzetOy != -1 || this.fiyatOy != -1) { return true; } return false; } @Override public String toString() { return "Sipariş " + this.getPrice() + " TL (" + DateFormat.getInstance().format(this.getOrderTime()) + ")"; } /* Bağlantı silinir */ public void killOrder() { this.restoran.killOrder(this); this.musteri.killOrder(this); } public double getPrice() { if (this.tutar != -1) return this.tutar; double price = 0; for(Object o: this.yemekVeMenuler) { if(o instanceof Fiyatlandirilabilir) { price += ((Fiyatlandirilabilir)o).getPrice(); } } this.tutar = Order.applyDiscounts(this.musteri, price); long l = (int)Math.round(this.tutar * 100); // truncates this.tutar = l / 100.0; return this.tutar; } private static double applyDiscounts(Customer musteri,double tutar) { if (musteri.getType() == CONSTANT.GOLDCUSTOMER) { tutar = tutar - (tutar * CONSTANT.GOLDCUSTOMERDISCOUNT / 100); } else if (musteri.getType() == CONSTANT.URANIUMCUSTOMER) { tutar = tutar - (tutar * CONSTANT.URANIUMCUSTOMERDISCOUNT / 100); } return tutar; } /*** * Nesne yaratmadan belirli bir müşterinin belirli bir ürünü alması durumunda ne kadar * ödeyeceğini hesaplayan bir metottur. * * Müşteriye özel indirim (varsa) hesaba katılır. * * @param Müşteri * @param Yemek ve Menülerden oluşan vektör * @return Fiyat */ public static double askPrice(Customer c, Vector whatToAsk) { double price = 0; for(Object o: whatToAsk) { if(o instanceof Fiyatlandirilabilir) { price += ((Fiyatlandirilabilir)o).getPrice(); } } return ((double)((int)(Order.applyDiscounts(c, price) * 100))) / 100.0; } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | package proje.restaurant; import java.util.Vector; import proje.bootstrapper.Main; import proje.user.Operator; import proje.util.CustomerOfARestaurant; import proje.util.SortableList; @SuppressWarnings("unchecked") public final class Restaurant implements Comparable { private String restName; private String adress; private Vector<proje.restaurant.Menu> menuler = new Vector<Menu>(); private Vector<Yemek> yemekler = new Vector<Yemek>(); private SortableList<Order> orders = new SortableList<Order>(); // Gelmiş geçmiş tüm siparişler private Operator operator; /* Restoranın sorumlusu */ public Restaurant (String restName, String adress, Operator operator) { this.adress = adress; this.restName = restName; this.operator = operator; operator.setSormluOldRestoran(this); Main.restaurants.add(this); } public SortableList<Order> getOrders() { return this.orders; } public void setName(String n) {this.restName=n;} public String getOperatorName() { return this.operator.getFirstName() + " " + this.operator.getLastName(); } public String getOperatorFirstName() { return this.operator.getFirstName(); } public String getOperatorLastName() { return this.operator.getLastName(); } public SortableList<CustomerOfARestaurant> getAllCustomersOfRestaurant() { SortableList<CustomerOfARestaurant> c = new SortableList<CustomerOfARestaurant>(); boolean done; for (Order o: this.getOrders()) { done = false; for (CustomerOfARestaurant cc: c) { if (o.getCustomer() == cc.c) { cc.number++; done = true; break; } } if(!done) { c.addElement(new CustomerOfARestaurant(o.getCustomer())); } } c.sortSortableOnes(true); return c; } public Operator getOperatorObject() { return this.operator; } public void setOperatorName(String first, String last) { this.operator.setFirstName(first); this.operator.setLastName(last); } public String getAdress() { return this.adress; } public void setAdress(String adress) { this.adress = adress;} public Vector<Yemek> getYemekler() { return this.yemekler; } public Vector<Menu> getMenuler() { return this.menuler; } public void addYemek(Yemek yeniYemek){//sisteme yemek girer this.yemekler.add(yeniYemek); } /*** * Restorandan verilen yemeği siler. <b>Bu yemek aynı zamanda restoranın menülerinde varsa * oralardan da silinir.</b> * * Silinen yemek ve menüler kullanıcıların yaptıkları siparişlerde görünmeye devam eder. * Bu siparişlere verilen oylar ve yorumlar sistemde görünmeye devam edecektir. * * @param Silinecek Yemek */ public void deleteYemek(Yemek sil) { for(Menu m : this.menuler) { m.removeYemek(sil); } this.yemekler.remove(sil); } /*** * Restorandan verilen menüyü siler. * * Silinen menüler kullanıcıların yaptıkları siparişlerde görünmeye devam eder. * Bu siparişlere verilen oylar ve yorumlar sistemde görünmeye devam edecektir. * * @param Silinecek Menü */ public void deleteMenu(Menu sil) { this.menuler.remove(sil); } public void deleteRestaurant() { while (this.orders.size() != 0) { this.orders.firstElement().killOrder(); } Main.users.remove(this.operator); Main.restaurants.remove(this); System.gc(); } public void addMenu(Menu m){//sisteme menü girer this.menuler.add(m); } public void newOrder(Order o) { this.orders.add(o); } public void cancelOrder(Order o){ if(o.cancelOrder()==true){ orders.remove(o); } } public double getOrtPuan() { int i = 0; double top = 0; for(Order o: this.orders) { if (o.getGenelPuan() != -1) { i++; top += o.getGenelPuan(); } } return ((double)((int)((top + 0.0) / (i + 0.0) * 100))) / 100.0; } public int compareTo (Object o) { if (!(o instanceof Restaurant)) { throw new ClassCastException(); } return (int)((this.getOrtPuan() - ((Restaurant)o).getOrtPuan())*1000); } @Override public String toString() { return restName; } /* Hiçbir kontrol yapmadan verilen siparişi restorandan atar. */ public void killOrder(Order o) { this.orders.remove(o); } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | package proje.restaurant; public final class Yemek implements Fiyatlandirilabilir { private double fiyat; private String ad; public Yemek(String ad, double fiyat) { this.ad = ad; this.fiyat = fiyat; } public void setPrice(double f) { this.fiyat = f; } public double getPrice() { return this.fiyat; } public void setAd(String a) { this.ad = a; } public String getAd() { return this.ad; } @Override public String toString() { return this.ad; } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 | package proje.ui; import java.awt.CheckboxGroup; import java.awt.Frame; import java.awt.Dimension; import java.awt.Label; import java.awt.Rectangle; import java.awt.Button; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.DefaultListModel; import javax.swing.ImageIcon; import javax.swing.JTabbedPane; import javax.swing.JPanel; import javax.swing.JList; import javax.swing.JLabel; import java.awt.TextField; import java.awt.TextArea; import javax.swing.JComboBox; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import javax.swing.JScrollPane; import javax.swing.JButton; import proje.bootstrapper.Main; import proje.restaurant.Restaurant; import proje.restaurant.Yemek; import proje.user.Customer; import proje.user.Operator; import proje.user.User; import proje.user.Administrator; import proje.util.CONSTANT; import java.text.DateFormat; import java.awt.Font; public class Admin extends Frame { private static final long serialVersionUID = 1L; private JTabbedPane jTabbedPane = null; private JPanel restaurantPanel = null; private JPanel clientPanel = null; private JLabel jLabel = null; DefaultListModel listModel = new DefaultListModel(); DefaultListModel restaurants = new DefaultListModel(); DefaultListModel listOfMenu = new DefaultListModel(); DefaultListModel listOfOrder = new DefaultListModel(); private Label label = null; private Label label1 = null; private Label label2 = null; private Label label3 = null; private Label label5 = null; private TextField nameField = null; private TextField surnameField = null; private TextArea adresArea = null; private JComboBox fm = null; private TextField textField = null; private JLabel image = null; private Button registerButton = null; private Button deleteButton = null; private Button changedButton = null; private Label label6 = null; private JList restaurantList = null; private Label label7 = null; private TextField resnameField = null; private Label label8 = null; private TextArea resadressArea = null; private Label label9 = null; private JScrollPane jScrollPane1 = null; private JButton jButton = null; private String what; private Button button = null; private Button button1 = null; private Button deletebutton2 = null; private Label label12 = null; private JList foodList = null; private JScrollPane jScrollPane2 = null; DefaultListModel listOfFood = new DefaultListModel(); private Label label14 = null; private JList menuList = null; private JScrollPane jScrollPane3 = null; private Label label16 = null; private TextArea commentArea = null; private Label label17 = null; private Label label18 = null; private Label label19 = null; private Label label20 = null; private Label label21 = null; private JList clientList = null; private JScrollPane clientPane = null; private JScrollPane orderPane = null; private Label label22 = null; private Label label23 = null; private Label label24 = null; private Button rolButton = null; private Label label26 = null; private Label label27 = null; private Label label11 = null; CheckboxGroup cbg = new CheckboxGroup(); private Label label25 = null; private boolean changeMusteri; private boolean changeRestoran; private JComboBox typeBox = null; private Label label4 = null; private Customer c; private TextField opName = null; private TextField opLast = null; private Restaurant r; private JList orderList1 = null; /** * This is the default constructor */ public Admin() { super(); initialize(); /* Restoran da, müşteri de ekleme konumunda başlar */ yeniKayitaGecmeIslemleri(); newResProcess(); fill(); fillr(); } /** * This method initializes this * * @return void */ private void initialize() { this.setLayout(null); this.setSize(800, 600); this.setResizable(false); this.setTitle("Yönetici"); for (User a : Main.users) { if (a instanceof Administrator) { this.setTitle("Yönetici: " + a); break; } } this.add(getJTabbedPane(), null); this.addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent e) { System.exit(0); // windowClosing() } }); } public void shut_up() { this.setVisible(false); } /** * This method initializes jTabbedPane * * @return javax.swing.JTabbedPane */ private JTabbedPane getJTabbedPane() { if (jTabbedPane == null) { jTabbedPane = new JTabbedPane(); jTabbedPane.setBounds(new Rectangle(14, 40, 772, 546)); jTabbedPane.addTab("Lokanta İşlemleri", null, getRestaurantPanel(), null); jTabbedPane.addTab("Müsteri İşlemleri", null, getClientPanel(), null); } return jTabbedPane; } /** * This method initializes restaurantPanel * * @return javax.swing.JPanel */ private JPanel getRestaurantPanel() { if (restaurantPanel == null) { label11 = new Label(); label11.setBounds(new Rectangle(652, 226, 49, 22)); label11.setFont(new Font("Dialog", Font.BOLD, 12)); label11.setText(""); label24 = new Label(); label24.setBounds(new Rectangle(542, 226, 107, 22)); label24.setText("Seçili yemek fiyatı:"); label23 = new Label(); label23.setBounds(new Rectangle(654, 373, 48, 23)); label23.setFont(new Font("Dialog", Font.BOLD, 12)); label23.setText(""); label22 = new Label(); label22.setBounds(new Rectangle(544, 372, 105, 22)); label22.setText("Seçili menü fiyatı:"); label14 = new Label(); label14.setBounds(new Rectangle(235, 371, 68, 21)); label14.setText("Menüler:"); label12 = new Label(); label12.setBounds(new Rectangle(236, 222, 72, 19)); label12.setText("Yemekler:"); label9 = new Label(); label9.setBounds(new Rectangle(543, 13, 206, 21)); label9.setText("Operatörün adı ve soyadı:"); label8 = new Label(); label8.setBounds(new Rectangle(211, 45, 93, 22)); label8.setText("Adresi:"); label7 = new Label(); label7.setBounds(new Rectangle(210, 15, 93, 25)); label7.setText("Adı:"); label6 = new Label(); label6.setBounds(new Rectangle(11, 13, 182, 21)); label6.setFont(new Font("Dialog", Font.BOLD, 12)); label6.setText("Lokantalar"); restaurantPanel = new JPanel(); restaurantPanel.setLayout(null); restaurantPanel.add(label6, null); restaurantPanel.add(label7, null); restaurantPanel.add(getResnameField(), null); restaurantPanel.add(label8, null); restaurantPanel.add(getResadressArea(), null); restaurantPanel.add(label9, null); restaurantPanel.add(getJScrollPane1(), null); restaurantPanel.add(getButton(), null); restaurantPanel.add(getButton1(), null); restaurantPanel.add(getDeletebutton2(), null); restaurantPanel.add(label12, null); restaurantPanel.add(getJScrollPane2(), null); restaurantPanel.add(label14, null); restaurantPanel.add(getJScrollPane3(), null); restaurantPanel.add(label22, null); restaurantPanel.add(label23, null); restaurantPanel.add(label24, null); restaurantPanel.add(getRolButton(), null); restaurantPanel.add(label11, null); restaurantPanel.add(getOpName(), null); restaurantPanel.add(getOpLast(), null); } return restaurantPanel; } /** * This method initializes clientPanel * * @return javax.swing.JPanel */ private JPanel getClientPanel() { if (clientPanel == null) { label4 = new Label(); label4.setBounds(new Rectangle(215, 280, 319, 44)); label4.setMinimumSize(new Dimension(319, 44)); label4.setMaximumSize(new Dimension(319, 44)); label4.setText(""); label4.setVisible(false); label25 = new Label(); label25.setBounds(new Rectangle(215, 257, 82, 18)); label25.setText("Müşteri Tipi:"); label25.setVisible(true); label27 = new Label(); label27.setVisible(true); label27.setBounds(new Rectangle(700, 369, 58, 26)); label27.setText(""); label26 = new Label(); label26.setVisible(false); label26.setBounds(new Rectangle(579, 368, 107, 25)); label26.setText("Kullandığı oy sayısı:"); label21 = new Label(); label21.setBounds(new Rectangle(207, 393, 96, 20)); label21.setText("Siparişleri:"); label21.setVisible(false); label20 = new Label(); label20.setBounds(new Rectangle(315, 362, 210, 21)); label20.setText(" "); label20.setVisible(false); label19 = new Label(); label19.setBounds(new Rectangle(208, 364, 94, 20)); label19.setText("Son Teslim:"); label19.setVisible(false); label18 = new Label(); label18.setVisible(false); label18.setBounds(new Rectangle(699, 409, 61, 22)); label18.setText(""); label18.setVisible(true); label17 = new Label(); label17.setBounds(new Rectangle(576, 408, 119, 22)); label17.setText("Toplam sipariş sayısı:"); label17.setVisible(true); label17.setVisible(false); label16 = new Label(); label16.setBounds(new Rectangle(575, 198, 109, 23)); label16.setText("Son bıraktığı yorum:"); label16.setVisible(false); image = new JLabel(); image.setBounds(new Rectangle(575, 15, 141, 168)); label5 = new Label(); label5.setBounds(new Rectangle(216, 334, 87, 18)); label5.setText("Dış Görünüm:"); label3 = new Label(); label3.setBounds(new Rectangle(216, 222, 85, 20)); label3.setText("Cinsiyet:"); label2 = new Label(); label2.setBounds(new Rectangle(219, 90, 84, 22)); label2.setText("Adresi:"); label1 = new Label(); label1.setBounds(new Rectangle(219, 49, 84, 23)); label1.setText("Soyadı:"); label = new Label(); label.setBounds(new Rectangle(220, 13, 81, 25)); label.setText("Adı:"); jLabel = new JLabel(); jLabel.setBounds(new Rectangle(11, 12, 188, 22)); jLabel.setText("Müşteriler"); clientPanel = new JPanel(); clientPanel.setLayout(null); clientPanel.add(jLabel, null); clientPanel.add(label, null); clientPanel.add(label1, null); clientPanel.add(label2, null); clientPanel.add(label3, null); clientPanel.add(label5, null); clientPanel.add(getNameField(), null); clientPanel.add(getSurnameField(), null); clientPanel.add(getAdresArea(), null); clientPanel.add(getFm(), null); clientPanel.add(getTextField(), null); clientPanel.add(image, null); clientPanel.add(getRegisterButton(), null); clientPanel.add(getDeleteButton(), null); clientPanel.add(getChangedButton(), null); clientPanel.add(getJButton(), null); clientPanel.add(label16, null); clientPanel.add(getCommentArea(), null); clientPanel.add(label17, null); clientPanel.add(label18, null); clientPanel.add(label19, null); clientPanel.add(label20, null); clientPanel.add(label21, null); clientPanel.add(getClientPane(), null); clientPanel.add(getOrderPane(), null); clientPanel.add(label26, null); clientPanel.add(label27, null); clientPanel.add(label25, null); clientPanel.add(getTypeBox(), null); clientPanel.add(label4, null); } return clientPanel; } /** * This method initializes clientList * * @return javax.swing.JList */ private JList getClientList() { if (clientList == null) { clientList = new JList(listModel); ListSelectionListener listSelectionListener = new ListSelectionListener() { public void valueChanged(ListSelectionEvent listSelectionEvent) { boolean adjust = listSelectionEvent.getValueIsAdjusting(); if (!adjust) { // seçim varsa eger JList list = (JList) listSelectionEvent.getSource(); Object selectionValue = list.getSelectedValue(); listOfOrder.clear(); c = (Customer) selectionValue; if (c == null) return; duzenlemeModunaGecmeIslemleri(); if (c.getGender() == CONSTANT.FEMALE) { image.setIcon(new ImageIcon("bulent.jpg")); textField.setText(c.getLooklike()); } else { image.setIcon(new ImageIcon("muslum.jpg")); textField.setText(c.getLooklike()); } fm.setEditable(true); if (c.getGender() == CONSTANT.FEMALE) { fm.setSelectedItem("Süslü"); } else { fm.setSelectedItem("Sakallı"); } fm.setEditable(false); String a = ""; switch (c.getType()) { case CONSTANT.URANIUMCUSTOMER: a = "Uranyum"; break; case CONSTANT.GOLDCUSTOMER: a = "Gold"; break; case CONSTANT.SILVERCUSTOMER: a = "Silver"; break; } label4.setText("Müşteri " + a + " ayrıcalıklarına sahiptir."); typeBox.setEditable(true); if (c.getIsTypeCheckingAutomated()) { typeBox.setSelectedItem("(Otomatik)"); } else { typeBox.setSelectedItem(a); } typeBox.setEditable(false); nameField.setText(c.getFirstName()); surnameField.setText(c.getLastName()); String count; count = (c.getTotalOrderCount()) + ""; label18.setText(count); String vote; vote = c.getTotalVoteCount() + " "; label27.setText(vote); adresArea.setText(c.getAdress()); if (c.getLastOrderTime() == null) { label20.setText("(yok)"); } else { label20.setText(DateFormat.getInstance().format( c.getLastOrderTime())); } if (c.getLastCommentsUserWrote(1).size() != 0) { commentArea.setText(c.getLastCommentsUserWrote(1).elementAt(0)); } else { commentArea.setText("(henüz hiç yorum bırakmadı.)"); } for (proje.restaurant.Order o : c .getAllOrdersByCurrentUserSortedByDateDESC()) { listOfOrder.addElement(o); } } } }; clientList.addListSelectionListener(listSelectionListener); } return clientList; } /** * This method initializes nameField * * @return java.awt.TextField */ private TextField getNameField() { if (nameField == null) { nameField = new TextField(); nameField.setBounds(new Rectangle(311, 14, 211, 22)); } return nameField; } /** * This method initializes surnameField * * @return java.awt.TextField */ private TextField getSurnameField() { if (surnameField == null) { surnameField = new TextField(); surnameField.setBounds(new Rectangle(313, 48, 208, 24)); } return surnameField; } /** * This method initializes adresArea * * @return java.awt.TextArea */ private TextArea getAdresArea() { if (adresArea == null) { adresArea = new TextArea(); adresArea.setBounds(new Rectangle(315, 90, 208, 119)); } return adresArea; } /** * This method initializes fm * * @return javax.swing.JComboBox */ private JComboBox getFm() { if (fm == null) { fm = new JComboBox(); fm.setBounds(new Rectangle(315, 223, 208, 21)); fm.addItem("Süslü"); fm.addItem("Sakallı"); fm.setEditable(false); fm.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (fm.getSelectedItem() == "Süslü") { image.setIcon(new ImageIcon("bulent.jpg")); } else if (fm.getSelectedItem() == "Sakallı") { image.setIcon(new ImageIcon("muslum.jpg")); } } }); } return fm; } /** * This method initializes textField * * @return java.awt.TextField */ private TextField getTextField() { if (textField == null) { textField = new TextField(); textField.setBounds(new Rectangle(313, 329, 212, 21)); } return textField; } /** * This method initializes registerButton * * @return java.awt.Button */ private Button getRegisterButton() { if (registerButton == null) { registerButton = new Button(); registerButton.setBounds(new Rectangle(13, 471, 179, 25)); registerButton.setLabel("Yeni Kayıt"); registerButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // buraya basip basmamasina göre diger buton // degistirilecek yeniKayitaGecmeIslemleri(); } }); } return registerButton; } /** * This method initializes deleteButton * * @return java.awt.Button */ private Button getDeleteButton() { if (deleteButton == null) { deleteButton = new Button(); deleteButton.setBounds(new Rectangle(582, 433, 76, 35)); deleteButton.setLabel("Sil Gitsin!"); deleteButton.setVisible(true); deleteButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { c.deleteUser(); listModel.removeElement(c); yeniKayitaGecmeIslemleri(); } }); } return deleteButton; } /** * This method initializes changedButton * * @return java.awt.Button */ private Button getChangedButton() { if (changedButton == null) { changedButton = new Button(); changedButton.setBounds(new Rectangle(675, 433, 79, 33)); changedButton.setLabel("Güncelle :)"); changedButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { boolean choose; if (fm.getSelectedItem() == "Süslü") { choose = CONSTANT.FEMALE; } else { choose = CONSTANT.MALE; } /* Düzenle */ if (changeMusteri == true) { c.setFirstName(nameField.getText()); c.setLastName(surnameField.getText()); c.setAdress(adresArea.getText()); c.setGender(choose); c.setLooklike(textField.getText()); int tip; if (((String) (typeBox.getSelectedItem())) .equalsIgnoreCase("Silver")) { tip = CONSTANT.SILVERCUSTOMER; } else if (((String) (typeBox.getSelectedItem())) .equalsIgnoreCase("Gold")) { tip = CONSTANT.GOLDCUSTOMER; } else if (((String) (typeBox.getSelectedItem())) .equalsIgnoreCase("Uranyum")) { tip = CONSTANT.URANIUMCUSTOMER; } else { tip = CONSTANT.AUTO; } c.changeType(tip); listModel.clear(); fill(); } else { /* Ekle */ int tip; if (((String) (typeBox.getSelectedItem())) .equalsIgnoreCase("Silver")) { tip = CONSTANT.SILVERCUSTOMER; } else if (((String) (typeBox.getSelectedItem())) .equalsIgnoreCase("Gold")) { tip = CONSTANT.GOLDCUSTOMER; } else if (((String) (typeBox.getSelectedItem())) .equalsIgnoreCase("Uranyum")) { tip = CONSTANT.URANIUMCUSTOMER; } else { tip = CONSTANT.AUTO; } Customer cus = new Customer(nameField.getText(), surnameField.getText(), adresArea.getText(), choose, textField.getText(), tip); System.out.println(cus); listModel.clear(); fill(); } yeniKayitaGecmeIslemleri(); } }); } return changedButton; } private void fill() { for (User u : Main.users.sortSortableOnes(true)) { if (u instanceof Customer) { listModel.addElement(u); } } } /** * This method initializes restaurantList * * @return javax.swing.JList */ private JList getRestaurantList() { if (restaurantList == null) { restaurantList = new JList(restaurants); ListSelectionListener listSelectionListener = new ListSelectionListener() { public void valueChanged(ListSelectionEvent listSelectionEvent) { boolean adjust2 = listSelectionEvent.getValueIsAdjusting(); if (!adjust2) { // Eğer seçim varsa changeProcess(); JList list = (JList) listSelectionEvent.getSource(); Object selectionValue = list.getSelectedValue(); r = ((Restaurant) selectionValue); if(r==null) return; resnameField.setText(r.toString()); resadressArea.setText(r.getAdress()); opName.setText(r.getOperatorFirstName()); opLast.setText(r.getOperatorLastName()); label9.setVisible(true); for (proje.restaurant.Yemek y : r.getYemekler()) { listOfFood.addElement(y); } for (proje.restaurant.Menu m : r.getMenuler()) { listOfMenu.addElement(m); } } } }; restaurantList.addListSelectionListener(listSelectionListener); } return restaurantList; } /** * This method initializes resnameField * * @return java.awt.TextField */ private TextField getResnameField() { if (resnameField == null) { resnameField = new TextField(); resnameField.setBounds(new Rectangle(314, 15, 213, 23)); } return resnameField; } /** * This method initializes resadressArea * * @return java.awt.TextArea */ private TextArea getResadressArea() { if (resadressArea == null) { resadressArea = new TextArea(); resadressArea.setBounds(new Rectangle(314, 48, 212, 136)); } return resadressArea; } /** * This method initializes jScrollPane1 * * @return javax.swing.JScrollPane */ private JScrollPane getJScrollPane1() { if (jScrollPane1 == null) { jScrollPane1 = new JScrollPane(restaurantList); jScrollPane1.setBounds(new Rectangle(11, 43, 185, 427)); jScrollPane1.setViewportView(getRestaurantList()); } return jScrollPane1; } /** * This method initializes jButton * * @return javax.swing.JButton */ private JButton getJButton() { if (jButton == null) { jButton = new JButton(); jButton.setBounds(new Rectangle(577, 473, 181, 43)); jButton.setText("Rol değiştir"); jButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { shut_up(); what = "Admin"; Common common = new Common(what,r); common.setVisible(true); } }); } return jButton; } /** * This method initializes button * * @return java.awt.Button */ private Button getButton() { if (button == null) { button = new Button(); button.setBounds(new Rectangle(665, 407, 94, 31)); button.setLabel("Ekle/Düzenle"); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (changeRestoran) { r.setName(resnameField.getText()); r.setAdress(resadressArea.getText()); r.setOperatorName(opName.getText(), opLast.getText()); restaurants.clear(); fillr(); } else { Operator o = new Operator(opName.getText(), opLast.getText()); Restaurant r = new Restaurant(resnameField.getText(), resadressArea.getText(), o); System.out.println(r); restaurants.clear(); fillr(); } newResProcess(); } }); } return button; } private void newResProcess() { changeRestoran = false; button.setLabel("Ekle :)"); jScrollPane3.setVisible(false); jScrollPane2.setVisible(false); resnameField.setText(""); resadressArea.setText(""); label24.setVisible(false); label11.setVisible(false); label22.setVisible(false); label23.setVisible(false); opName.setText(""); opLast.setText(""); deletebutton2.setVisible(false); label14.setVisible(false); label12.setVisible(false); } private void changeProcess() { changeRestoran = true; button.setLabel("Düzenle"); listOfFood.clear(); listOfMenu.clear(); jScrollPane3.setVisible(true); jScrollPane2.setVisible(true); label24.setVisible(false); label11.setVisible(false); label22.setVisible(false); label23.setVisible(false); deletebutton2.setVisible(true); label14.setVisible(true); label12.setVisible(true); } /** * This method initializes button1 * * @return java.awt.Button */ private Button getButton1() { if (button1 == null) { button1 = new Button(); button1.setBounds(new Rectangle(12, 471, 183, 29)); button1.setLabel("Yeni Kayıt"); button1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { changeRestoran = true; newResProcess(); } }); } return button1; } private void duzenlemeModunaGecmeIslemleri() { label19.setVisible(true); label20.setVisible(true); label21.setVisible(true); orderList1.setVisible(true); orderPane.setVisible(true); commentArea.setVisible(true); label16.setVisible(true); label26.setVisible(true); label27.setVisible(true); label17.setVisible(true); label18.setVisible(true); deleteButton.setVisible(true); label4.setVisible(true); changeMusteri = true; changedButton.setLabel("Güncelle :)"); } private void yeniKayitaGecmeIslemleri() { image.setIcon(new ImageIcon("bulent.jpg")); deleteButton.setVisible(false); changedButton.setLabel("Ekle :)"); changeMusteri = false; label4.setVisible(false); nameField.setText(""); surnameField.setText(""); adresArea.setText(""); label16.setVisible(false); label17.setVisible(false); label18.setVisible(false); label19.setVisible(false); label20.setVisible(false); label21.setVisible(false); label26.setVisible(false); label27.setVisible(false); commentArea.setVisible(false); textField.setText(""); orderList1.setVisible(false); orderPane.setVisible(false); typeBox.setEditable(true); typeBox.setSelectedItem("(Otomatik)"); typeBox.setEditable(false); fm.setEditable(true); fm.setSelectedItem("Süslü"); fm.setEditable(false); } /** * This method initializes deletebutton2 * * @return java.awt.Button */ private Button getDeletebutton2() { if (deletebutton2 == null) { deletebutton2 = new Button(); deletebutton2.setBounds(new Rectangle(665, 443, 95, 31)); deletebutton2.setLabel("Sil!"); deletebutton2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { r.deleteRestaurant(); restaurants.removeElement(r); newResProcess(); } }); } return deletebutton2; } /** * This method initializes foodList * * @return javax.swing.JList */ private JList getFoodList() { if (foodList == null) { foodList = new JList(listOfFood); foodList.setBounds(new Rectangle(0, 0, 210, 127)); ListSelectionListener listSelectionListener = new ListSelectionListener() { public void valueChanged(ListSelectionEvent listSelectionEvent) { boolean adjust2 = listSelectionEvent.getValueIsAdjusting(); if (!adjust2) { // seçim varsa eger JList list = (JList) listSelectionEvent.getSource(); Object selectionValue = list.getSelectedValue(); label24.setVisible(true); label11.setVisible(true); Yemek y = (Yemek) selectionValue; if (y == null) return; String pr = y.getPrice() + " "; label11.setText(pr); } } }; foodList.addListSelectionListener(listSelectionListener); } return foodList; } /** * This method initializes jScrollPane2 * * @return javax.swing.JScrollPane */ private JScrollPane getJScrollPane2() { if (jScrollPane2 == null) { jScrollPane2 = new JScrollPane(foodList); jScrollPane2.setBounds(new Rectangle(314, 222, 221, 136)); jScrollPane2.setViewportView(getFoodList()); } return jScrollPane2; } /** * This method initializes menuList * * @return javax.swing.JList */ private JList getMenuList() { if (menuList == null) { menuList = new JList(listOfMenu); ListSelectionListener listSelectionListener = new ListSelectionListener() { public void valueChanged(ListSelectionEvent listSelectionEvent) { boolean adjust2 = listSelectionEvent.getValueIsAdjusting(); if (!adjust2) { // seçim varsa eger JList list = (JList) listSelectionEvent.getSource(); Object selectionValue = list.getSelectedValue(); label22.setVisible(true); label23.setVisible(true); proje.restaurant.Menu m = ((proje.restaurant.Menu) selectionValue); if (m == null) return; String pr = m.getPrice() + " "; label23.setText(pr); } } }; menuList.addListSelectionListener(listSelectionListener); } return menuList; } /** * This method initializes jScrollPane3 * * @return javax.swing.JScrollPane */ private JScrollPane getJScrollPane3() { if (jScrollPane3 == null) { jScrollPane3 = new JScrollPane(menuList); jScrollPane3.setBounds(new Rectangle(313, 370, 221, 148)); jScrollPane3.setViewportView(getMenuList()); } return jScrollPane3; } /** * This method initializes commentArea * * @return java.awt.TextArea */ private TextArea getCommentArea() { if (commentArea == null) { commentArea = new TextArea(); commentArea.setBounds(new Rectangle(574, 233, 177, 124)); commentArea.setEnabled(true); commentArea.setEditable(false); commentArea.setVisible(false); } return commentArea; } /** * This method initializes clientPane * * @return javax.swing.JScrollPane */ private JScrollPane getClientPane() { if (clientPane == null) { clientPane = new JScrollPane(clientList); clientPane.setBounds(new Rectangle(11, 45, 183, 422)); clientPane.setViewportView(getClientList()); } return clientPane; } /** * This method initializes orderPane * * @return javax.swing.JScrollPane */ private JScrollPane getOrderPane() { if (orderPane == null) { orderPane = new JScrollPane(orderList1); orderPane.setBounds(new Rectangle(313, 392, 215, 123)); orderPane.setViewportView(getOrderList1()); } return orderPane; } /** * This method initializes rolButton * * @return java.awt.Button */ private Button getRolButton() { if (rolButton == null) { rolButton = new Button(); rolButton.setBounds(new Rectangle(664, 476, 95, 35)); rolButton.setLabel("Rol Değiştir!"); rolButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { shut_up(); Common common = new Common("Admin",r); common.setVisible(true); } }); } return rolButton; } /** * This method initializes typeBox * * @return javax.swing.JComboBox */ private JComboBox getTypeBox() { if (typeBox == null) { typeBox = new JComboBox(); typeBox.setBounds(new Rectangle(316, 254, 207, 23)); typeBox.addItem("(Otomatik)"); typeBox.addItem("Silver"); typeBox.addItem("Gold"); typeBox.addItem("Uranyum"); typeBox.setEditable(false); } return typeBox; } private void fillr() { for (Restaurant r : Main.restaurants) { restaurants.addElement(r); } } /** * This method initializes opName * * @return java.awt.TextField */ private TextField getOpName() { if (opName == null) { opName = new TextField(); opName.setBounds(new Rectangle(601, 37, 146, 21)); } return opName; } /** * This method initializes opLast * * @return java.awt.TextField */ private TextField getOpLast() { if (opLast == null) { opLast = new TextField(); opLast.setBounds(new Rectangle(602, 62, 146, 23)); } return opLast; } /** * This method initializes orderList1 * * @return javax.swing.JList */ private JList getOrderList1() { if (orderList1 == null) { orderList1 = new JList(listOfOrder); orderList1.setBounds(new Rectangle(215, 367, 209, 126)); } return orderList1; } } // @jve:decl-index=0:visual-constraint="40,57" |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 | package proje.ui; import java.awt.Frame; import javax.swing.JTabbedPane; import java.awt.Rectangle; import javax.swing.JPanel; import java.awt.GridBagLayout; import javax.swing.DefaultListModel; import javax.swing.JComboBox; import javax.swing.JList; import javax.swing.JScrollPane; import java.awt.Label; import java.awt.TextField; import java.awt.TextArea; import java.awt.Button; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JLabel; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import proje.restaurant.Order; import proje.restaurant.Restaurant; import proje.restaurant.Yemek; import proje.util.CONSTANT; import proje.util.CustomerOfARestaurant; import proje.util.SortableList; import java.awt.List; import java.text.DateFormat; import java.util.Vector; import javax.swing.JButton; import java.awt.GridBagConstraints; import java.awt.Font; public class Boss extends Frame { private static final long serialVersionUID = 1L; DefaultListModel orderModel = new DefaultListModel(); DefaultListModel foodlistModel = new DefaultListModel(); DefaultListModel addListModel = new DefaultListModel(); DefaultListModel listOfMenu = new DefaultListModel(); private JTabbedPane jTabbedPane = null; private JPanel sortPanel = null; private JComboBox orderBox = null; private JList orderList = null; private JScrollPane jScrollPane = null; private Label label = null; private Label label1 = null; private Label label2 = null; private Label label3 = null; private TextField nameField = null; private TextField surnameField = null; private TextArea adresArea = null; private Label label4 = null; private Label label5 = null; private TextField textField1 = null; private Label label6 = null; private TextField textField2 = null; private Label label7 = null; private TextArea foodmenuArea = null; private Label label9 = null; private TextField priceField = null; private Label label10 = null; private TextArea commentArea = null; private Button rolButton = null; private JPanel icerikPaneli = null; private Label label13 = null; private Button ok = null; private Button button2 = null; private Label label18 = null; private Label label19 = null; private Button newPerson = null; private Button addButton = null; private JList menuList = null; private JScrollPane menuPane = null; private JList foodList1 = null; private JScrollPane foodListPane = null; private JList addList = null; private JScrollPane addFoodPane1 = null; private JLabel jLabel4 = null; private JLabel jLabel5 = null; private TextField menuName = null; private TextField menuPr = null; private Label label20 = null; private Label label21 = null; private TextField foodName = null; private TextField foodPrice = null; private Restaurant r; private proje.restaurant.Menu mm; private Button newMenu = null; private Button newFood = null; private proje.restaurant.Yemek y; private boolean newMenuVariable = false; private boolean editMenuVariable = false; private boolean editYemekVariable = false; private JButton deleteFood = null; Yemek aktifSeciliYemek = null; Yemek aktifSeciliEklenecekYemek = null; Order aktif = null; // @jve:decl-index=0: private JButton deleteMenu = null; private JButton outOfMenu = null; private Label labelHiz = null; private Label label8 = null; private Label label11 = null; private Label label111 = null; private Label dataHiz = null; private Label dataLezzet = null; private Label dataFiyat = null; private JPanel genelBilgilerPanel = null; private Label label12 = null; private Label label14 = null; private Label label141 = null; private TextField textRestoranAdi = null; private TextField textAdres = null; private JButton buttonRestGuncelle = null; private JButton rolDegistir = null; private JPanel musteriPanel = null; private List list = null; private Label label142 = null; private TextField dataPuan = null; private Button btnSiparisiYolaCikar = null; private Button btnSiparisTeslimEdildi = null; /** * This is the default constructor */ public Boss(Restaurant r) { super(); this.r = r; initialize(); } /** * This method initializes this * * @return void */ private void initialize() { this.setLayout(null); this.setSize(800, 600); this.setResizable(false); this.setTitle("Restoran Operatörü: " + r.getOperatorName()); this.add(getJTabbedPane(), null); textRestoranAdi.setText(r.toString()); textAdres.setText(r.getAdress()); dataPuan.setText(r.getOrtPuan() + " / 3.00"); /* Müşterileri sıralı raporlama algoritması */ SortableList<CustomerOfARestaurant> cus = r.getAllCustomersOfRestaurant(); for (CustomerOfARestaurant c: cus) { list.add(c.c.getFirstName() + " " + c.c.getLastName() + " (Bu rest. " + c.number + " alışveriş)"); } normalProcess(); filler(); this.addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent e) { System.exit(0); // windowClosing() } }); } public void shut_up() { this.setVisible(false); } private void fillMenus() { for (proje.restaurant.Menu m : r.getMenuler()) { listOfMenu.addElement(m); } } /** * This method initializes jTabbedPane * * @return javax.swing.JTabbedPane */ private JTabbedPane getJTabbedPane() { if (jTabbedPane == null) { jTabbedPane = new JTabbedPane(); jTabbedPane.setBounds(new Rectangle(5, 30, 791, 561)); jTabbedPane.addTab("Genel Bilgiler", null, getGenelBilgilerPanel(), null); jTabbedPane.addTab("Siparişler", null, getSortPanel(), null); jTabbedPane.addTab("Menüler & Yemekler", null, getIcerikPaneli(), null); jTabbedPane.addTab("Müşteriler", null, getMusteriPanel(), null); } return jTabbedPane; } /** * This method initializes sortPanel * * @return javax.swing.JPanel */ private JPanel getSortPanel() { if (sortPanel == null) { dataFiyat = new Label(); dataFiyat.setBounds(new Rectangle(678, 347, 87, 28)); dataFiyat.setText(""); dataLezzet = new Label(); dataLezzet.setBounds(new Rectangle(676, 314, 85, 30)); dataLezzet.setText(""); dataHiz = new Label(); dataHiz.setBounds(new Rectangle(676, 279, 85, 26)); dataHiz.setText(""); label111 = new Label(); label111.setBounds(new Rectangle(560, 345, 102, 27)); label111.setText("Fiyat:"); label11 = new Label(); label11.setBounds(new Rectangle(558, 313, 105, 26)); label11.setText("Lezzet:"); label8 = new Label(); label8.setBounds(new Rectangle(557, 278, 102, 28)); label8.setText("Hız:"); labelHiz = new Label(); labelHiz.setBounds(new Rectangle(557, 241, 206, 27)); labelHiz.setText("Bu siparişin puanlaması:"); label10 = new Label(); label10.setBounds(new Rectangle(553, 19, 207, 24)); label10.setText("Şöyle demiş:"); label9 = new Label(); label9.setBounds(new Rectangle(239, 476, 90, 22)); label9.setText("ToplamTutar:"); label7 = new Label(); label7.setBounds(new Rectangle(238, 300, 94, 25)); label7.setText("Detayı:"); label6 = new Label(); label6.setBounds(new Rectangle(242, 266, 91, 23)); label6.setText("Teslim Tarihi:"); label5 = new Label(); label5.setBounds(new Rectangle(241, 236, 90, 21)); label5.setText("Verilme Tarihi:"); label4 = new Label(); label4.setBounds(new Rectangle(240, 208, 92, 19)); label4.setText("Siparişin:"); label3 = new Label(); label3.setBounds(new Rectangle(239, 108, 94, 20)); label3.setText("Adresi:"); label2 = new Label(); label2.setBounds(new Rectangle(241, 77, 92, 21)); label2.setText("Soyadı:"); label1 = new Label(); label1.setBounds(new Rectangle(242, 48, 93, 21)); label1.setText("Adı:"); label = new Label(); label.setBounds(new Rectangle(240, 18, 109, 22)); label.setText("Siparişi verenin:"); sortPanel = new JPanel(); sortPanel.setLayout(null); sortPanel.add(getOrderBox(), null); sortPanel.add(getJScrollPane(), null); sortPanel.add(label, null); sortPanel.add(label1, null); sortPanel.add(label2, null); sortPanel.add(label3, null); sortPanel.add(getNameField(), null); sortPanel.add(getSurnameField(), null); sortPanel.add(getAdresArea(), null); sortPanel.add(label4, null); sortPanel.add(label5, null); sortPanel.add(getTextField1(), null); sortPanel.add(label6, null); sortPanel.add(getTextField2(), null); sortPanel.add(label7, null); sortPanel.add(getFoodmenuArea(), null); sortPanel.add(label9, null); sortPanel.add(getPriceField(), null); sortPanel.add(label10, null); sortPanel.add(getCommentArea(), null); sortPanel.add(getRolButton(), null); sortPanel.add(labelHiz, null); sortPanel.add(label8, null); sortPanel.add(label11, null); sortPanel.add(label111, null); sortPanel.add(dataHiz, null); sortPanel.add(dataLezzet, null); sortPanel.add(dataFiyat, null); sortPanel.add(getBtnSiparisiYolaCikar(), null); sortPanel.add(getBtnSiparisTeslimEdildi(), null); } return sortPanel; } /** * This method initializes orderBox * * @return javax.swing.JComboBox */ private JComboBox getOrderBox() { if (orderBox == null) { orderBox = new JComboBox(); orderBox.setBounds(new Rectangle(16, 16, 209, 28)); orderBox.addItem("Tüm Siparişler"); orderBox.addItem("Onay Bekleyenler"); orderBox.addItem("Yolda Olanlar"); orderBox.addItem("Yerine Ulaşmış Siparişler"); orderBox.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { filler(); } }); } return orderBox; } private void filler() { nameField.setText(""); surnameField.setText(""); adresArea.setText(""); textField1.setText(""); textField2.setText(""); foodmenuArea.setText(""); priceField.setText(""); commentArea.setText(""); dataHiz.setText(""); dataLezzet.setText(""); dataFiyat.setText(""); btnSiparisiYolaCikar.setEnabled(false); btnSiparisTeslimEdildi.setEnabled(false); orderModel.clear(); for(Order o: r.getOrders().sortSortableOnes(true)) { String secili = (String)orderBox.getSelectedItem(); int flag = -1; if (secili.equals("Onay Bekleyenler")) flag = CONSTANT.NEWORDER; if (secili.equals("Yolda Olanlar")) flag = CONSTANT.ORDERINPROGRESS; if (secili.equals("Yerine Ulaşmış Siparişler")) flag = CONSTANT.DELIVEREDORDER; if (flag == -1 || o.getOrderStatus() == flag) { orderModel.addElement(o); } } } /** * This method initializes orderList * * @return javax.swing.JList */ private JList getOrderList() { if (orderList == null) { orderList = new JList(orderModel); ListSelectionListener listSelectionListener = new ListSelectionListener() { public void valueChanged(ListSelectionEvent listSelectionEvent) { boolean adjust = listSelectionEvent.getValueIsAdjusting(); if (!adjust) { JList list = (JList) listSelectionEvent.getSource(); Object selectionValue = list.getSelectedValue(); if (selectionValue == null) return; Order o = (Order)selectionValue; aktif = o; nameField.setText(o.getCustomer().getFirstName()); surnameField.setText(o.getCustomer().getLastName()); adresArea.setText(o.getCustomer().getAdress()); textField1.setText(DateFormat.getInstance().format(o.getOrderTime())); textField2.setText((o.getCompleteTime() == null ? "(henüz yerine ulaşmadı" : DateFormat.getInstance().format(o.getCompleteTime()))); foodmenuArea.setText(""); for(Object obj: o.getOrderDetails()) { if (obj instanceof proje.restaurant.Menu) { foodmenuArea.setText(foodmenuArea.getText().concat("**** Menü: " + ((proje.restaurant.Menu)obj).getName() + " (" + ((proje.restaurant.Menu)obj).getPrice() + " TL)")); } if (obj instanceof Yemek) { foodmenuArea.setText(foodmenuArea.getText().concat("**** Yemek: " + ((proje.restaurant.Yemek)obj).getAd() + " (" + ((proje.restaurant.Yemek)obj).getPrice() + " TL)")); } } priceField.setText(o.getPrice() + "TL (müşt.indrm.dahil)"); commentArea.setText(o.getComment() == null ? "(yok)" : o.getComment()); dataHiz.setText(o.getHizPuan() < 0 ? "(oy vermedi)" : o.getHizPuan() + ""); dataLezzet.setText(o.getLezzetPuan() < 0 ? "(oy vermedi)" : o.getLezzetPuan() + ""); dataFiyat.setText(o.getFiyatPuan() < 0 ? "(oy vermedi)" : o.getFiyatPuan() + ""); if(o.isOrderNew()) { btnSiparisiYolaCikar.setEnabled(true); btnSiparisTeslimEdildi.setEnabled(true); } if (o.isOrderInProgress()) { btnSiparisiYolaCikar.setEnabled(false); btnSiparisTeslimEdildi.setEnabled(true); } if (o.isOrderDelivered()) { btnSiparisiYolaCikar.setEnabled(false); btnSiparisTeslimEdildi.setEnabled(false); } } } }; orderList.addListSelectionListener(listSelectionListener); } return orderList; } /** * This method initializes jScrollPane * * @return javax.swing.JScrollPane */ private JScrollPane getJScrollPane() { if (jScrollPane == null) { jScrollPane = new JScrollPane(orderList); jScrollPane.setBounds(new Rectangle(18, 62, 204, 442)); jScrollPane.setViewportView(getOrderList()); } return jScrollPane; } /** * This method initializes nameField * * @return java.awt.TextField */ private TextField getNameField() { if (nameField == null) { nameField = new TextField(); nameField.setBounds(new Rectangle(344, 48, 186, 21)); nameField.setEditable(false); } return nameField; } /** * This method initializes surnameField * * @return java.awt.TextField */ private TextField getSurnameField() { if (surnameField == null) { surnameField = new TextField(); surnameField.setBounds(new Rectangle(343, 75, 188, 24)); surnameField.setEditable(false); } return surnameField; } /** * This method initializes adresArea * * @return java.awt.TextArea */ private TextArea getAdresArea() { if (adresArea == null) { adresArea = new TextArea(); adresArea.setBounds(new Rectangle(344, 109, 187, 95)); adresArea.setEditable(false); } return adresArea; } /** * This method initializes textField1 * * @return java.awt.TextField */ private TextField getTextField1() { if (textField1 == null) { textField1 = new TextField(); textField1.setBounds(new Rectangle(344, 235, 182, 24)); textField1.setEditable(false); } return textField1; } /** * This method initializes textField2 * * @return java.awt.TextField */ private TextField getTextField2() { if (textField2 == null) { textField2 = new TextField(); textField2.setBounds(new Rectangle(344, 266, 182, 24)); textField2.setEditable(false); } return textField2; } /** * This method initializes foodmenuArea * * @return java.awt.TextArea */ private TextArea getFoodmenuArea() { if (foodmenuArea == null) { foodmenuArea = new TextArea(); foodmenuArea.setBounds(new Rectangle(344, 300, 181, 170)); foodmenuArea.setColumns(50); foodmenuArea.setEditable(false); } return foodmenuArea; } /** * This method initializes priceField * * @return java.awt.TextField */ private TextField getPriceField() { if (priceField == null) { priceField = new TextField(); priceField.setBounds(new Rectangle(343, 474, 180, 25)); priceField.setEditable(false); } return priceField; } /** * This method initializes commentArea * * @return java.awt.TextArea */ private TextArea getCommentArea() { if (commentArea == null) { commentArea = new TextArea(); commentArea.setBounds(new Rectangle(554, 48, 208, 183)); commentArea.setEditable(false); commentArea.setColumns(50); } return commentArea; } /** * This method initializes rolButton * * @return java.awt.Button */ private Button getRolButton() { if (rolButton == null) { rolButton = new Button(); rolButton.setBounds(new Rectangle(563, 473, 200, 47)); rolButton.setLabel("Rol Değiştir"); rolButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { shut_up(); Common c = new Common("Boss", r); c.setVisible(true); } }); } return rolButton; } /** * This method initializes icerikPaneli * * @return javax.swing.JPanel */ private JPanel getIcerikPaneli() { if (icerikPaneli == null) { label21 = new Label(); label21.setBounds(new Rectangle(345, 407, 99, 21)); label21.setText("Fiyatı:"); label20 = new Label(); label20.setBounds(new Rectangle(343, 378, 100, 20)); label20.setText("Yemek adı:"); jLabel5 = new JLabel(); jLabel5.setBounds(new Rectangle(9, 406, 92, 21)); jLabel5.setText("Fiyatı:"); jLabel4 = new JLabel(); jLabel4.setBounds(new Rectangle(9, 380, 93, 21)); jLabel4.setText("Menü adı:"); label19 = new Label(); label19.setBounds(new Rectangle(556, 13, 219, 22)); label19.setText("Seçilen menünün yemekleri"); label18 = new Label(); label18.setBounds(new Rectangle(13, 11, 121, 20)); label18.setText("Menü Listesi"); label13 = new Label(); label13.setBounds(new Rectangle(341, 15, 154, 19)); label13.setText("Restoran Yemekleri:"); icerikPaneli = new JPanel(); icerikPaneli.setLayout(null); icerikPaneli.add(label13, null); icerikPaneli.add(getOk(), null); icerikPaneli.add(getButton2(), null); icerikPaneli.add(label18, null); icerikPaneli.add(label19, null); icerikPaneli.add(getNewPerson(), null); icerikPaneli.add(getAddButton(), null); icerikPaneli.add(getMenuPane(), null); icerikPaneli.add(getFoodListPane(), null); icerikPaneli.add(getAddFoodPane1(), null); icerikPaneli.add(jLabel4, null); icerikPaneli.add(jLabel5, null); icerikPaneli.add(getMenuName(), null); icerikPaneli.add(getMenuPr(), null); icerikPaneli.add(label20, null); icerikPaneli.add(label21, null); icerikPaneli.add(getFoodName(), null); icerikPaneli.add(getFoodPrice(), null); icerikPaneli.add(getNewMenu(), null); icerikPaneli.add(getNewFood(), null); icerikPaneli.add(getDeleteFood(), null); icerikPaneli.add(getDeleteMenu(), null); icerikPaneli.add(getOutOfMenu(), null); } return icerikPaneli; } /** * This method initializes ok * * @return java.awt.Button */ private Button getOk() { if (ok == null) { ok = new Button(); ok.setBounds(new Rectangle(531, 439, 81, 28)); ok.setLabel("Ok!"); ok.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (editYemekVariable) { y.setAd(foodName.getText()); String p = foodPrice.getText(); double pr; try { pr = Double.parseDouble(p); } catch (NumberFormatException e1) { pr = 0.01; } y.setPrice(pr); } else { String p = foodPrice.getText(); double pr; try { pr = Double.parseDouble(p); } catch (NumberFormatException e1) { pr = 0.01; } Yemek y = new Yemek(foodName.getText(), pr); r.addYemek(y); } normalProcess(); } }); } return ok; } /** * This method initializes button2 * * @return java.awt.Button */ private Button getButton2() { if (button2 == null) { button2 = new Button(); button2.setBounds(new Rectangle(194, 440, 81, 26)); button2.setLabel("Ok!"); // bu buton güncelle veya ekle arasında gidecek button2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (newMenuVariable == true) { /* Yeni menü eklenecek */ String p = menuPr.getText(); double pr; try { pr = Double.parseDouble(p); } catch (NumberFormatException e1) { pr = 0.01; } Vector<Yemek> eklenecekYemekListesi = new Vector<Yemek>(); int i = 0; for(i=0;i<addListModel.size();i++) { eklenecekYemekListesi.add((Yemek)(addListModel.elementAt(i))); } proje.restaurant.Menu m = new proje.restaurant.Menu( menuName.getText(), pr, eklenecekYemekListesi); r.addMenu(m); } else { mm.setName(menuName.getText()); String price = menuPr.getText(); double pr; try { pr = Double.parseDouble(price); } catch (NumberFormatException e1) { pr = 0.01; } mm.setPrice(pr); listOfMenu.clear(); fillMenus(); } normalProcess(); } }); } return button2; } /** * This method initializes menuList * * @return javax.swing.JList */ private JList getMenuList() { if (menuList == null) { menuList = new JList(listOfMenu); ListSelectionListener listSelectionListener = new ListSelectionListener() { public void valueChanged(ListSelectionEvent listSelectionEvent) { boolean adjust2 = listSelectionEvent.getValueIsAdjusting(); if (!adjust2) { JList list = (JList) listSelectionEvent.getSource(); Object selectionValue = list.getSelectedValue(); if (selectionValue == null) return; editMenuProcess(); mm = (proje.restaurant.Menu) selectionValue; addListModel.clear(); fillAddList(); menuName.setText(mm.getName()); String p = mm.getPrice() + ""; menuPr.setText(p); } } }; menuList.addListSelectionListener(listSelectionListener); } return menuList; } private void fillAddList() { for (proje.restaurant.Yemek y : mm.getMenuYemekleri()) { addListModel.addElement(y); } } private void fillFoodList() { for (proje.restaurant.Yemek y : r.getYemekler()) { foodlistModel.addElement(y); } } /** * This method initializes foodList1 * * @return javax.swing.JList */ private JList getFoodList1() { if (foodList1 == null) { foodList1 = new JList(foodlistModel); ListSelectionListener listSelectionListener = new ListSelectionListener() { public void valueChanged(ListSelectionEvent listSelectionEvent) { boolean adjust = listSelectionEvent.getValueIsAdjusting(); if (!adjust) { JList list = (JList) listSelectionEvent.getSource(); Object selectionValue = list.getSelectedValue(); if (selectionValue == null) return; if(newMenuVariable || editMenuVariable) { aktifSeciliYemek = (Yemek) selectionValue; } else { editFoodProcess(); y = (Yemek) selectionValue; foodName.setText(y.getAd()); String pr = y.getPrice() + ""; foodPrice.setText(pr); } } } }; foodList1.addListSelectionListener(listSelectionListener); } return foodList1; } /** * This method initializes newPerson * * @return java.awt.Button */ private Button getNewPerson() { if (newPerson == null) { newPerson = new Button(); newPerson.setBounds(new Rectangle(595, 476, 187, 51)); newPerson.setLabel("Rol değiştir"); newPerson.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { shut_up(); Common c = new Common("Boss", r); c.setVisible(true); } }); } return newPerson; } /** * This method initializes addButton * * @return java.awt.Button */ private Button getAddButton() { if (addButton == null) { addButton = new Button(); addButton.setBounds(new Rectangle(541, 82, 80, 32)); addButton.setLabel("Ekle ->"); addButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (aktifSeciliYemek != null) { addListModel.addElement(aktifSeciliYemek); if(editMenuVariable) { mm.addYemek(aktifSeciliYemek); } } } }); } return addButton; } /** * This method initializes menuPane * * @return javax.swing.JScrollPane */ private JScrollPane getMenuPane() { if (menuPane == null) { menuPane = new JScrollPane(menuList); menuPane.setBounds(new Rectangle(10, 44, 195, 324)); menuPane.setViewportView(getMenuList()); } return menuPane; } /** * This method initializes foodListPane * * @return javax.swing.JScrollPane */ private JScrollPane getFoodListPane() { if (foodListPane == null) { foodListPane = new JScrollPane(foodList1); foodListPane.setBounds(new Rectangle(342, 46, 197, 321)); foodListPane.setViewportView(getFoodList1()); } return foodListPane; } /** * This method initializes addL�st * * @return javax.swing.JList */ private JList getAddList() { if (addList == null) { addList = new JList(addListModel); ListSelectionListener listSelectionListener = new ListSelectionListener() { public void valueChanged(ListSelectionEvent listSelectionEvent) { boolean adjust = listSelectionEvent.getValueIsAdjusting(); if (!adjust) { JList list = (JList) listSelectionEvent.getSource(); Object selectionValue = list.getSelectedValue(); if (selectionValue == null) return; if(newMenuVariable || editMenuVariable) { aktifSeciliEklenecekYemek = (Yemek) selectionValue; } // Yemek yem = (Yemek) selectionValue; } } }; addList.addListSelectionListener(listSelectionListener); } return addList; } /** * This method initializes addFoodPane1 * * @return javax.swing.JScrollPane */ private JScrollPane getAddFoodPane1() { if (addFoodPane1 == null) { addFoodPane1 = new JScrollPane(addList); addFoodPane1.setBounds(new Rectangle(626, 48, 155, 123)); addFoodPane1.setViewportView(getAddList()); } return addFoodPane1; } /** * This method initializes menuName * * @return java.awt.TextField */ private TextField getMenuName() { if (menuName == null) { menuName = new TextField(); menuName.setBounds(new Rectangle(112, 381, 164, 21)); } return menuName; } /** * This method initializes menuPr * * @return java.awt.TextField */ private TextField getMenuPr() { if (menuPr == null) { menuPr = new TextField(); menuPr.setBounds(new Rectangle(112, 408, 163, 20)); } return menuPr; } /** * This method initializes foodName * * @return java.awt.TextField */ private TextField getFoodName() { if (foodName == null) { foodName = new TextField(); foodName.setBounds(new Rectangle(449, 379, 165, 19)); } return foodName; } /** * This method initializes foodPrice * * @return java.awt.TextField */ private TextField getFoodPrice() { if (foodPrice == null) { foodPrice = new TextField(); foodPrice.setBounds(new Rectangle(450, 407, 164, 21)); } return foodPrice; } /** * This method initializes newMenu * * @return java.awt.Button */ private Button getNewMenu() { if (newMenu == null) { newMenu = new Button(); newMenu.setBounds(new Rectangle(13, 483, 77, 40)); newMenu.setLabel("Yeni Menü"); newMenu.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { newMenuProcess(); } }); } return newMenu; } private void newMenuProcess() { /* Görünmez yap */ newMenuVariable = true; editMenuVariable = false; editYemekVariable = false; /* Menü */ jLabel4.setVisible(true); jLabel5.setVisible(true); menuName.setVisible(true); menuPr.setVisible(true); menuName.setText(""); menuPr.setText(""); button2.setVisible(true); button2.setLabel("Ekle"); deleteMenu.setVisible(false); /* Yemek */ label20.setVisible(false); label21.setVisible(false); foodName.setVisible(false); foodPrice.setVisible(false); ok.setVisible(false); deleteFood.setVisible(false); /* Öbürleri */ addButton.setVisible(true); outOfMenu.setVisible(true); addFoodPane1.setVisible(true); addListModel.clear(); label19.setVisible(true); label19.setText("Yeni menüye eklenen yemekler listesi:"); } private void normalProcess() { listOfMenu.clear(); addListModel.clear(); foodlistModel.clear(); fillMenus(); fillFoodList(); newMenuVariable = false; editMenuVariable = false; editYemekVariable = false; /* Menü */ jLabel4.setVisible(false); jLabel5.setVisible(false); menuName.setVisible(false); menuPr.setVisible(false); button2.setVisible(false); deleteMenu.setVisible(false); /* Yemek */ label20.setVisible(false); label21.setVisible(false); foodName.setVisible(false); foodPrice.setVisible(false); ok.setVisible(false); deleteFood.setVisible(false); /* Öbürleri */ addButton.setVisible(false); outOfMenu.setVisible(false); addFoodPane1.setVisible(false); label19.setVisible(false); } /** * This method initializes newFood * * @return java.awt.Button */ private Button getNewFood() { if (newFood == null) { newFood = new Button(); newFood.setBounds(new Rectangle(356, 482, 81, 42)); newFood.setLabel("Yeni Yemek"); newFood.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { newFoodProcess(); } }); } return newFood; } private void editMenuProcess() { newMenuVariable = false; editMenuVariable = true; editYemekVariable = false; /* Menü */ jLabel4.setVisible(true); jLabel5.setVisible(true); menuName.setVisible(true); menuPr.setVisible(true); button2.setVisible(true); button2.setLabel("Düzenle"); deleteMenu.setVisible(true); /* Yemek */ label20.setVisible(false); label21.setVisible(false); foodName.setVisible(false); foodPrice.setVisible(false); ok.setVisible(false); deleteFood.setVisible(false); /* Öbürleri */ addButton.setVisible(true); outOfMenu.setVisible(true); addFoodPane1.setVisible(true); addListModel.clear(); label19.setVisible(true); label19.setText("Düzenlenen menüye eklenen yemekler listesi:"); } private void editFoodProcess() { newMenuVariable = false; editMenuVariable = false; editYemekVariable = true; /* Menü */ jLabel4.setVisible(false); jLabel5.setVisible(false); menuName.setVisible(false); menuPr.setVisible(false); button2.setVisible(false); deleteMenu.setVisible(false); /* Yemek */ label20.setVisible(true); label21.setVisible(true); foodName.setVisible(true); foodPrice.setVisible(true); ok.setVisible(true); ok.setLabel("Düzenle"); deleteFood.setVisible(true); /* Öbürleri */ addButton.setVisible(false); outOfMenu.setVisible(false); addFoodPane1.setVisible(false); label19.setVisible(false); } private void newFoodProcess() { newMenuVariable = false; editMenuVariable = false; editYemekVariable = false; /* Menü */ jLabel4.setVisible(false); jLabel5.setVisible(false); menuName.setVisible(false); menuPr.setVisible(false); button2.setVisible(false); deleteMenu.setVisible(false); /* Yemek */ label20.setVisible(true); label21.setVisible(true); foodName.setVisible(true); foodPrice.setVisible(true); foodName.setText(""); foodPrice.setText(""); ok.setVisible(true); ok.setLabel("Ekle"); deleteFood.setVisible(false); /* Öbürleri */ addButton.setVisible(false); outOfMenu.setVisible(false); addFoodPane1.setVisible(false); label19.setVisible(false); } /** * This method initializes deleteFood * * @return javax.swing.JButton */ private JButton getDeleteFood() { if (deleteFood == null) { deleteFood = new JButton(); deleteFood.setBounds(new Rectangle(434, 436, 83, 31)); deleteFood.setText("Sil!"); deleteFood.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { r.deleteYemek(y); normalProcess(); } }); } return deleteFood; } /** * This method initializes deleteMenu * * @return javax.swing.JButton */ private JButton getDeleteMenu() { if (deleteMenu == null) { deleteMenu = new JButton(); deleteMenu.setBounds(new Rectangle(111, 439, 80, 25)); deleteMenu.setText("Sil!"); deleteMenu.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { if (mm != null) r.deleteMenu(mm); normalProcess(); } }); } return deleteMenu; } /** * This method initializes outOfMenu * * @return javax.swing.JButton */ private JButton getOutOfMenu() { if (outOfMenu == null) { outOfMenu = new JButton(); outOfMenu.setBounds(new Rectangle(541, 117, 82, 34)); outOfMenu.setText("<- Çıkar"); outOfMenu.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (aktifSeciliEklenecekYemek != null) { addListModel.removeElement(aktifSeciliEklenecekYemek); if(editMenuVariable) { mm.removeYemek(aktifSeciliEklenecekYemek); } } } }); } return outOfMenu; } /** * This method initializes genelBilgilerPanel * * @return javax.swing.JPanel */ private JPanel getGenelBilgilerPanel() { if (genelBilgilerPanel == null) { label142 = new Label(); label142.setBounds(new Rectangle(66, 157, 170, 51)); label142.setText("Ort. puan:"); label142.setFont(new Font("Dialog", Font.PLAIN, 36)); label141 = new Label(); label141.setBounds(new Rectangle(32, 212, 208, 44)); label141.setText("Tam Adresi:"); label141.setFont(new Font("Dialog", Font.PLAIN, 36)); label14 = new Label(); label14.setBounds(new Rectangle(6, 105, 228, 50)); label14.setFont(new Font("Dialog", Font.PLAIN, 36)); label14.setText("Restoran Adı:"); label12 = new Label(); label12.setBounds(new Rectangle(14, 17, 516, 28)); label12.setText("Sevgili yönetici dilerseniz restoranınızın bilgilerini güncelleyebilirsiniz."); genelBilgilerPanel = new JPanel(); genelBilgilerPanel.setLayout(null); genelBilgilerPanel.add(label12, null); genelBilgilerPanel.add(label14, null); genelBilgilerPanel.add(label141, null); genelBilgilerPanel.add(getTextRestoranAdi(), null); genelBilgilerPanel.add(getTextAdres(), null); genelBilgilerPanel.add(getButtonRestGuncelle(), null); genelBilgilerPanel.add(getRolDegistir(), null); genelBilgilerPanel.add(label142, null); genelBilgilerPanel.add(getDataPuan(), null); } return genelBilgilerPanel; } /** * This method initializes textRestoranAdi * * @return java.awt.TextField */ private TextField getTextRestoranAdi() { if (textRestoranAdi == null) { textRestoranAdi = new TextField(); textRestoranAdi.setBounds(new Rectangle(241, 105, 529, 52)); textRestoranAdi.setFont(new Font("Dialog", Font.PLAIN, 36)); } return textRestoranAdi; } /** * This method initializes textAdres * * @return java.awt.TextField */ private TextField getTextAdres() { if (textAdres == null) { textAdres = new TextField(); textAdres.setBounds(new Rectangle(241, 210, 530, 145)); textAdres.setFont(new Font("Dialog", Font.PLAIN, 36)); } return textAdres; } /** * This method initializes buttonRestGuncelle * * @return javax.swing.JButton */ private JButton getButtonRestGuncelle() { if (buttonRestGuncelle == null) { buttonRestGuncelle = new JButton(); buttonRestGuncelle.setBounds(new Rectangle(560, 426, 201, 48)); buttonRestGuncelle.setText("Güncelle"); buttonRestGuncelle.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { r.setName(textRestoranAdi.getText()); r.setAdress(textAdres.getText()); } }); } return buttonRestGuncelle; } /** * This method initializes rolDegistir * * @return javax.swing.JButton */ private JButton getRolDegistir() { if (rolDegistir == null) { rolDegistir = new JButton(); rolDegistir.setBounds(new Rectangle(561, 478, 201, 46)); rolDegistir.setText("Rol Değiştir"); rolDegistir.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { shut_up(); Common c = new Common("Boss", r); c.setVisible(true); } }); } return rolDegistir; } /** * This method initializes musteriPanel * * @return javax.swing.JPanel */ private JPanel getMusteriPanel() { if (musteriPanel == null) { GridBagConstraints gridBagConstraints = new GridBagConstraints(); gridBagConstraints.fill = GridBagConstraints.BOTH; gridBagConstraints.gridy = 0; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; gridBagConstraints.gridx = 0; musteriPanel = new JPanel(); musteriPanel.setLayout(new GridBagLayout()); musteriPanel.add(getList(), gridBagConstraints); } return musteriPanel; } /** * This method initializes list * * @return java.awt.List */ private List getList() { if (list == null) { list = new List(); } return list; } /** * This method initializes dataPuan * * @return java.awt.TextField */ private TextField getDataPuan() { if (dataPuan == null) { dataPuan = new TextField(); dataPuan.setBounds(new Rectangle(241, 161, 531, 48)); dataPuan.setEditable(false); dataPuan.setFont(new Font("Dialog", Font.PLAIN, 36)); } return dataPuan; } /** * This method initializes btnSiparisiYolaCikar * * @return java.awt.Button */ private Button getBtnSiparisiYolaCikar() { if (btnSiparisiYolaCikar == null) { btnSiparisiYolaCikar = new Button(); btnSiparisiYolaCikar.setBounds(new Rectangle(560, 378, 205, 44)); btnSiparisiYolaCikar.setLabel("Sipariş Yola Çıktı"); btnSiparisiYolaCikar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { if (aktif == null) return; aktif.setOrderInProgress(); filler(); } }); } return btnSiparisiYolaCikar; } /** * This method initializes btnSiparisTeslimEdildi * * @return java.awt.Button */ private Button getBtnSiparisTeslimEdildi() { if (btnSiparisTeslimEdildi == null) { btnSiparisTeslimEdildi = new Button(); btnSiparisTeslimEdildi.setBounds(new Rectangle(555, 427, 210, 43)); btnSiparisTeslimEdildi.setLabel("Sipariş Yerine Ulaştı"); btnSiparisTeslimEdildi.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { if (aktif == null) return; aktif.setOrderDelivered(); filler(); } }); } return btnSiparisTeslimEdildi; } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 | package proje.ui; /* henüz gelmeyenlerle yeni siparişler aynı değil sanırım görüntülenmeli mi */ import java.awt.Frame; import javax.swing.JTabbedPane; import java.awt.Rectangle; import javax.swing.JPanel; import java.awt.CheckboxGroup; import java.awt.Label; import javax.swing.DefaultListModel; import javax.swing.JList; import javax.swing.JScrollPane; import javax.swing.JComboBox; import java.awt.Button; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.TextArea; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import javax.swing.JLabel; import proje.bootstrapper.Main; import proje.restaurant.Fiyatlandirilabilir; import proje.restaurant.Order; import proje.restaurant.Restaurant; import proje.restaurant.Yemek; import proje.user.Customer; import proje.util.CONSTANT; import java.text.DateFormat; import java.util.Vector; import java.awt.Font; import java.awt.Choice; import java.awt.GridBagLayout; import java.awt.List; import java.awt.GridBagConstraints; public class Client extends Frame { private static final long serialVersionUID = 1L; private JTabbedPane jTabbedPane = null; private JPanel orderPanel = null; CheckboxGroup cbg = new CheckboxGroup(); CheckboxGroup cbg2 = new CheckboxGroup(); CheckboxGroup cbg3 = new CheckboxGroup(); private JPanel restaurantPanel = null; private Label label1 = null; private Label label2 = null; private Label label3 = null; private JComboBox restaurantBox = null; DefaultListModel listModel = new DefaultListModel(); DefaultListModel listModel2 = new DefaultListModel(); DefaultListModel listofMenu = new DefaultListModel(); DefaultListModel listOfFood = new DefaultListModel(); DefaultListModel choose = new DefaultListModel(); DefaultListModel icerik = new DefaultListModel(); private Label label9 = null; private Label lblNormalFiyat = null; private Label label14 = null; private Label label18 = null; private Button button = null; private JList menuList = null; private JScrollPane menuPane = null; private JList foodList = null; private JScrollPane foodPane = null; private Button change = null; private Label label = null; private TextArea textArea = null; private Button changed = null; private JList otherOrderList = null; private JScrollPane otherOrderPane = null; private Customer c = new Customer("", "", "", true, ""); // @jve:decl-index=0: private JLabel oy = null; private JLabel oyy = null; private Restaurant r; private Label lblSeciliFiyat = null; private JList chooseList = null; private JScrollPane choosePane = null; // @jve:decl-index=0: private proje.restaurant.Order o; private Button cikar = null; private proje.restaurant.Menu tiklanmisMenu; private proje.restaurant.Yemek tiklanmisYemek; private Object tiklanmisSepettekiYemek; Object selectionValuem; private JList iceriklist = null; private JScrollPane icerikPane = null; private JComboBox siparisFiltre = null; private Button btnIptal = null; private Label lblFiyat = null; private Label lblRestoran = null; private TextArea txtDetails = null; private Choice oyLezzet = null; private Choice oyFiyat = null; private Choice oyHiz = null; private Label sipDurum = null; private Label label6 = null; private Label label10 = null; private Label orderDate = null; private Label completeDate = null; private Label label5 = null; private Label label12 = null; private Button btnMenuEkle = null; private Button btnYemekEkle = null; private Label label7 = null; private Label label121 = null; private Label lblIndirimliFiyat = null; private Label label1211 = null; private Button btnSiparisVer = null; private JPanel tumRestoranlar = null; private List allrestList = null; /** * This is the default constructor */ public Client(Customer c) { super(); this.c = c; initialize(); } /** * This method initializes this * * @return void */ private void initialize() { this.setLayout(null); this.setSize(800, 600); this.setResizable(false); this.setTitle("Müşteri: " + c.getFirstName() + " " + c.getLastName()); this.add(getJTabbedPane(), null); this.addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent e) { System.exit(0); } }); fillOrderBox(); } private void fillOrderBox() { listModel2.clear(); String secili = (String)siparisFiltre.getSelectedItem(); int flag = -1; if (secili.equals("Onay Bekleyenler")) flag = CONSTANT.NEWORDER; if (secili.equals("Yolda Olanlar")) flag = CONSTANT.ORDERINPROGRESS; if (secili.equals("Yerine Ulaşmış Siparişler")) flag = CONSTANT.DELIVEREDORDER; for (proje.restaurant.Order or : c.getAllOrdersByCurrentUserSortedByDateDESC()) { if (flag == -1 || or.getOrderStatus() == flag) { listModel2.addElement(or); } } lblRestoran.setText(""); orderDate.setText(""); completeDate.setText(""); lblFiyat.setText(""); txtDetails.setText(""); textArea.setText(""); textArea.setEnabled(false); oyLezzet.select("(yok)"); oyLezzet.setEnabled(false); oyHiz.select("(yok)"); oyHiz.setEnabled(false); oyFiyat.select("(yok)"); oyFiyat.setEnabled(false); btnIptal.setEnabled(false); button.setEnabled(false); sipDurum.setText(""); } public void shut_up() { this.setVisible(false); } /** * This method initializes jTabbedPane * * @return javax.swing.JTabbedPane */ private JTabbedPane getJTabbedPane() { if (jTabbedPane == null) { jTabbedPane = new JTabbedPane(); jTabbedPane.setBounds(new Rectangle(15, 33, 768, 551)); jTabbedPane.addTab("Yeni Sipariş Ver", null, getOrderPanel(), null); jTabbedPane.addTab("Siparişleriniz", null, getRestaurantPanel(), null); jTabbedPane.addTab("Tüm Restoranlar", null, getTumRestoranlar(), null); } return jTabbedPane; } /** * This method initializes orderPanel * * @return javax.swing.JPanel */ private JPanel getOrderPanel() { if (orderPanel == null) { label1211 = new Label(); label1211.setBounds(new Rectangle(346, 477, 185, 37)); label1211.setAlignment(Label.LEFT); label1211.setText("4. Siparişinizi verin!"); label1211.setFont(new Font("Dialog", Font.BOLD, 18)); lblIndirimliFiyat = new Label(); lblIndirimliFiyat.setBounds(new Rectangle(516, 445, 232, 26)); lblIndirimliFiyat.setText(""); label121 = new Label(); label121.setBounds(new Rectangle(347, 231, 290, 31)); label121.setAlignment(Label.LEFT); label121.setText("3. Sepetinizi Doldurun"); label121.setFont(new Font("Dialog", Font.BOLD, 18)); label7 = new Label(); label7.setBounds(new Rectangle(346, 113, 113, 24)); label7.setText("Menüdeki Yiyecekler:"); label12 = new Label(); label12.setBounds(new Rectangle(15, 77, 213, 30)); label12.setAlignment(Label.LEFT); label12.setText("2. İstediklerinizi Seçin"); label12.setFont(new Font("Dialog", Font.BOLD, 18)); label5 = new Label(); label5.setBounds(new Rectangle(187, 18, 213, 19)); label5.setName(""); label5.setText("(Lokantalar puanlarına göre sıralıdır.)"); lblSeciliFiyat = new Label(); lblSeciliFiyat.setVisible(true); lblSeciliFiyat.setBounds(new Rectangle(414, 21, 335, 49)); lblSeciliFiyat.setFont(new Font("Dialog", Font.BOLD, 36)); lblSeciliFiyat.setName("lblSeciliFiyat"); lblSeciliFiyat.setText(""); oyy = new JLabel(); oyy.setBounds(new Rectangle(357, 44, 42, 25)); oy = new JLabel(); oy.setBounds(new Rectangle(328, 43, 24, 26)); oy.setText("Oy:"); lblNormalFiyat = new Label(); lblNormalFiyat.setBounds(new Rectangle(350, 445, 160, 24)); label3 = new Label(); label3.setBounds(new Rectangle(14, 309, 158, 22)); label3.setAlignment(Label.LEFT); label3.setText("Restorandaki Yemekler:"); label3.setVisible(true); label2 = new Label(); label2.setBounds(new Rectangle(14, 112, 138, 23)); label2.setAlignment(Label.LEFT); label2.setText("Restorandaki Menüler:"); label2.setVisible(true); label1 = new Label(); label1.setBounds(new Rectangle(16, 12, 170, 26)); label1.setAlignment(Label.LEFT); label1.setFont(new Font("Dialog", Font.BOLD, 18)); label1.setText("1. Lokantayı Seçin"); orderPanel = new JPanel(); orderPanel.setLayout(null); orderPanel.add(label1, null); orderPanel.add(label2, null); orderPanel.add(label3, null); orderPanel.add(getRestaurantBox(), null); orderPanel.add(lblNormalFiyat, null); orderPanel.add(getMenuPane(), null); orderPanel.add(getFoodPane(), null); orderPanel.add(getChange(), null); orderPanel.add(oy, null); orderPanel.add(oyy, null); orderPanel.add(lblSeciliFiyat, null); orderPanel.add(getChoosePane(), null); orderPanel.add(getCikar(), null); orderPanel.add(getIcerikPane(), null); orderPanel.add(label5, null); orderPanel.add(label12, null); orderPanel.add(getBtnMenuEkle(), null); orderPanel.add(getBtnYemekEkle(), null); orderPanel.add(label7, null); orderPanel.add(label121, null); orderPanel.add(lblIndirimliFiyat, null); orderPanel.add(label1211, null); orderPanel.add(getBtnSiparisVer(), null); } return orderPanel; } /** * This method initializes restaurantPanel * * @return javax.swing.JPanel */ private JPanel getRestaurantPanel() { if (restaurantPanel == null) { completeDate = new Label(); completeDate.setBounds(new Rectangle(566, 393, 165, 20)); completeDate.setText(""); orderDate = new Label(); orderDate.setBounds(new Rectangle(565, 349, 167, 18)); orderDate.setText(""); label10 = new Label(); label10.setBounds(new Rectangle(557, 370, 175, 22)); label10.setText("Sip.teslim zamanı:"); label6 = new Label(); label6.setBounds(new Rectangle(558, 329, 173, 19)); label6.setText("Sip.verilme zamanı:"); sipDurum = new Label(); sipDurum.setBounds(new Rectangle(255, 416, 474, 27)); sipDurum.setFont(new Font("Dialog", Font.ITALIC, 24)); sipDurum.setText(""); lblRestoran = new Label(); lblRestoran.setBounds(new Rectangle(253, 25, 383, 29)); lblRestoran.setFont(new Font("Dialog", Font.BOLD, 24)); lblRestoran.setText(""); lblFiyat = new Label(); lblFiyat.setBounds(new Rectangle(642, 25, 108, 28)); lblFiyat.setFont(new Font("Dialog", Font.BOLD, 24)); lblFiyat.setText("Tutar"); label = new Label(); label.setBounds(new Rectangle(255, 155, 157, 22)); label.setText("Sipariş hakkında yorumum:"); label18 = new Label(); label18.setBounds(new Rectangle(254, 360, 64, 21)); label18.setText("Fiyat:"); label14 = new Label(); label14.setBounds(new Rectangle(253, 388, 63, 20)); label14.setText("Hız:"); label9 = new Label(); label9.setBounds(new Rectangle(254, 330, 64, 23)); label9.setText("Lezzet:"); restaurantPanel = new JPanel(); restaurantPanel.setLayout(null); restaurantPanel.add(label9, null); restaurantPanel.add(label14, null); restaurantPanel.add(label18, null); restaurantPanel.add(getButton(), null); restaurantPanel.add(label, null); restaurantPanel.add(getTextArea(), null); restaurantPanel.add(getChanged(), null); restaurantPanel.add(getOtherOrderPane(), null); restaurantPanel.add(getSiparisFiltre(), null); restaurantPanel.add(getBtnIptal(), null); restaurantPanel.add(lblFiyat, null); restaurantPanel.add(lblRestoran, null); restaurantPanel.add(getTxtDetails(), null); restaurantPanel.add(getOyLezzet(), null); restaurantPanel.add(getOyFiyat(), null); restaurantPanel.add(getOyHiz(), null); restaurantPanel.add(sipDurum, null); restaurantPanel.add(label6, null); restaurantPanel.add(label10, null); restaurantPanel.add(orderDate, null); restaurantPanel.add(completeDate, null); } return restaurantPanel; } /** * This method initializes restaurantBox * * @return javax.swing.JComboBox */ private JComboBox getRestaurantBox() { if (restaurantBox == null) { restaurantBox = new JComboBox(); restaurantBox.setBounds(new Rectangle(16, 43, 306, 26)); for (Restaurant r : Main.restaurants.sortSortableOnes(true)) { restaurantBox.addItem(r); } resetNewOrderWindow(); restaurantBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { resetNewOrderWindow(); } }); } return restaurantBox; } /** * This method initializes button * * @return java.awt.Button */ private Button getButton() { if (button == null) { button = new Button(); button.setBounds(new Rectangle(252, 486, 205, 28)); button.setLabel("Oyumu & Yorumlarımı Kaydet"); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { o.setComment(textArea.getText()); if (oyHiz.getSelectedItem().equals("(yok)")) { o.voteForHiz(-1); } else if (oyHiz.getSelectedItem().equals("İyi")) { o.voteForHiz(2); } else if (oyHiz.getSelectedItem().equals("Orta")) { o.voteForHiz(1); } else { o.voteForHiz(0); } if (oyFiyat.getSelectedItem().equals("(yok)")) { o.voteForFiyat(-1); } else if (oyFiyat.getSelectedItem().equals("İyi")) { o.voteForFiyat(2); } else if (oyFiyat.getSelectedItem().equals("Orta")) { o.voteForFiyat(1); } else { o.voteForFiyat(0); } if (oyLezzet.getSelectedItem().equals("(yok)")) { o.voteForLezzet(-1); } else if (oyLezzet.getSelectedItem().equals("İyi")) { o.voteForLezzet(2); } else if (oyLezzet.getSelectedItem().equals("Orta")) { o.voteForLezzet(1); } else { o.voteForLezzet(0); } fillOrderBox(); } }); } return button; } /** * This method initializes menuList * * @return javax.swing.JList */ private JList getMenuList() { if (menuList == null) { menuList = new JList(listofMenu); ListSelectionListener listSelectionListener = new ListSelectionListener() { public void valueChanged(ListSelectionEvent listSelectionEvent) { boolean adjust2 = listSelectionEvent.getValueIsAdjusting(); if (!adjust2) { // Eğer seçim varsa JList list = (JList) listSelectionEvent.getSource(); Object selectionValue = list.getSelectedValue(); tiklanmisMenu = (proje.restaurant.Menu) selectionValue; if (tiklanmisMenu == null) return; lblSeciliFiyat.setText(tiklanmisMenu.getPrice() + " TL"); /* Menüdeki yiyecekler */ icerik.clear(); for(Yemek y: tiklanmisMenu.getMenuYemekleri()) { icerik.addElement(y); } } } }; menuList.addListSelectionListener(listSelectionListener); } return menuList; } /** * This method initializes menuPane * * @return javax.swing.JScrollPane */ private JScrollPane getMenuPane() { if (menuPane == null) { menuPane = new JScrollPane(menuList); menuPane.setBounds(new Rectangle(14, 139, 309, 166)); menuPane.setViewportView(getMenuList()); menuPane.setVisible(true); } return menuPane; } /** * This method initializes foodList * * @return javax.swing.JList */ private JList getFoodList() { if (foodList == null) { foodList = new JList(listOfFood); foodList.setBounds(new Rectangle(591, 93, 148, 159)); ListSelectionListener listSelectionListener = new ListSelectionListener() { public void valueChanged(ListSelectionEvent listSelectionEvent) { boolean adjust2 = listSelectionEvent.getValueIsAdjusting(); if (!adjust2) { // Eğer seçim varsa JList list = (JList) listSelectionEvent.getSource(); Object selectionValue = list.getSelectedValue(); tiklanmisYemek = (proje.restaurant.Yemek) selectionValue; if (tiklanmisYemek == null) return; lblSeciliFiyat.setText(tiklanmisYemek.getPrice() + " TL"); } } }; foodList.addListSelectionListener(listSelectionListener); } return foodList; } /** * This method initializes foodPane * * @return javax.swing.JScrollPane */ private JScrollPane getFoodPane() { if (foodPane == null) { foodPane = new JScrollPane(foodList); foodPane.setBounds(new Rectangle(14, 337, 309, 177)); foodPane.setViewportView(getFoodList()); foodPane.setVisible(true); } return foodPane; } /** * This method initializes change * * @return java.awt.Button */ private Button getChange() { if (change == null) { change = new Button(); change.setBounds(new Rectangle(627, 81, 123, 48)); change.setLabel("Rol Değiştir"); change.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { shut_up(); Common com = new Common("Client", c); com.setVisible(true); } }); } return change; } /** * This method initializes textArea * * @return java.awt.TextArea */ private TextArea getTextArea() { if (textArea == null) { textArea = new TextArea(); textArea.setBounds(new Rectangle(254, 183, 498, 134)); } return textArea; } /** * This method initializes changed * * @return java.awt.Button */ private Button getChanged() { if (changed == null) { changed = new Button(); changed.setBounds(new Rectangle(462, 456, 291, 57)); changed.setLabel("Rol Değiştir"); changed.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { shut_up(); Common com = new Common("Client", c); com.setVisible(true); } }); } return changed; } /** * This method initializes otherOrderList * * @return javax.swing.JList */ private JList getOtherOrderList() { if (otherOrderList == null) { otherOrderList = new JList(listModel2); ListSelectionListener listSelectionListener = new ListSelectionListener() { public void valueChanged(ListSelectionEvent listSelectionEvent) { boolean adjust2 = listSelectionEvent.getValueIsAdjusting(); if (!adjust2) { // Eğer seçim varsa JList list = (JList) listSelectionEvent.getSource(); Object selectionValue = list.getSelectedValue(); if(selectionValue == null) return; o = (proje.restaurant.Order) selectionValue; lblRestoran.setText(o.getRestaurant().toString()); if (o.isOrderNew()) { /* Yeni */ lblFiyat.setText(o.getPrice() + " TL"); txtDetails.setText(""); for(Object obj: o.getOrderDetails()) { if (obj instanceof proje.restaurant.Menu) { txtDetails.setText(txtDetails.getText().concat("**** Menü: " + ((proje.restaurant.Menu)obj).getName() + " (" + ((proje.restaurant.Menu)obj).getPrice() + " TL)")); } if (obj instanceof Yemek) { txtDetails.setText(txtDetails.getText().concat("**** Yemek: " + ((proje.restaurant.Yemek)obj).getAd() + " (" + ((proje.restaurant.Yemek)obj).getPrice() + " TL)")); } } sipDurum.setText("Siparişiniz onay bekliyor."); textArea.setText("(sipariş size ulaşmadan yorum bırakamazsınız."); textArea.setEnabled(false); oyLezzet.select("(yok)"); oyLezzet.setEnabled(false); oyHiz.select("(yok)"); oyHiz.setEnabled(false); oyFiyat.select("(yok)"); oyFiyat.setEnabled(false); btnIptal.setEnabled(true); button.setEnabled(false); orderDate.setText(DateFormat.getInstance().format(o.getOrderTime())); completeDate.setText((o.getCompleteTime() == null ? "(henüz size ulaşmadı" : DateFormat.getInstance().format(o.getCompleteTime()))); } else if (o.isOrderInProgress()) { /* Yolda */ sipDurum.setText("Siparişiniz yolda."); lblFiyat.setText(o.getPrice() + " TL"); txtDetails.setText(""); for(Object obj: o.getOrderDetails()) { if (obj instanceof proje.restaurant.Menu) { txtDetails.setText(txtDetails.getText().concat("**** Menü: " + ((proje.restaurant.Menu)obj).getName() + " (" + ((proje.restaurant.Menu)obj).getPrice() + " TL)")); } if (obj instanceof Yemek) { txtDetails.setText(txtDetails.getText().concat("**** Yemek: " + ((proje.restaurant.Yemek)obj).getAd() + " (" + ((proje.restaurant.Yemek)obj).getPrice() + " TL)")); } } textArea.setText("(sipariş size ulaşmadan yorum bırakamazsınız.)"); textArea.setEnabled(false); oyLezzet.select("(yok)"); oyLezzet.setEnabled(false); oyHiz.select("(yok)"); oyHiz.setEnabled(false); oyFiyat.select("(yok)"); oyFiyat.setEnabled(false); btnIptal.setEnabled(false); button.setEnabled(false); orderDate.setText(DateFormat.getInstance().format(o.getOrderTime())); completeDate.setText((o.getCompleteTime() == null ? "(henüz size ulaşmadı" : DateFormat.getInstance().format(o.getCompleteTime()))); } else { /* Ulaştı */ lblFiyat.setText(o.getPrice() + " TL"); txtDetails.setText(""); for(Object obj: o.getOrderDetails()) { if (obj instanceof proje.restaurant.Menu) { txtDetails.setText(txtDetails.getText().concat("**** Menü: " + ((proje.restaurant.Menu)obj).getName() + " (" + ((proje.restaurant.Menu)obj).getPrice() + " TL)")); } if (obj instanceof Yemek) { txtDetails.setText(txtDetails.getText().concat("**** Yemek: " + ((proje.restaurant.Yemek)obj).getAd() + " (" + ((proje.restaurant.Yemek)obj).getPrice() + " TL)")); } } sipDurum.setText("Siparişiniz teslim edildi."); textArea.setText(o.getComment() == null ? "" : o.getComment()); textArea.setEnabled(true); int puan = o.getLezzetPuan(); if(puan == -1) { oyLezzet.select("(yok)"); } else if (puan == 3) { oyLezzet.select("İyi"); } else if (puan == 2) { oyLezzet.select("Orta"); } else { oyLezzet.select("Kötü"); } puan = o.getHizPuan(); if(puan == -1) { oyHiz.select("(yok)"); } else if (puan == 3) { oyHiz.select("İyi"); } else if (puan == 2) { oyHiz.select("Orta"); } else { oyHiz.select("Kötü"); } puan = o.getFiyatPuan(); if(puan == -1) { oyFiyat.select("(yok)"); } else if (puan == 3) { oyFiyat.select("İyi"); } else if (puan == 2) { oyFiyat.select("Orta"); } else { oyFiyat.select("Kötü"); } oyLezzet.setEnabled(true); oyHiz.setEnabled(true); oyFiyat.setEnabled(true); btnIptal.setEnabled(false); button.setEnabled(true); orderDate.setText(DateFormat.getInstance().format(o.getOrderTime())); completeDate.setText((o.getCompleteTime() == null ? "(henüz size ulaşmadı" : DateFormat.getInstance().format(o.getCompleteTime()))); } } } }; otherOrderList.addListSelectionListener(listSelectionListener); } return otherOrderList; } /** * This method initializes otherOrderPane * * @return javax.swing.JScrollPane */ private JScrollPane getOtherOrderPane() { if (otherOrderPane == null) { otherOrderPane = new JScrollPane(otherOrderList); otherOrderPane.setBounds(new Rectangle(17, 61, 222, 456)); otherOrderPane.setViewportView(getOtherOrderList()); } return otherOrderPane; } /** * This method initializes chooseList * * @return javax.swing.JList */ private JList getChooseList() { if (chooseList == null) { chooseList = new JList(choose); chooseList.setVisible(true); ListSelectionListener listSelectionListener = new ListSelectionListener() { public void valueChanged(ListSelectionEvent listSelectionEvent) { boolean adjust2 = listSelectionEvent.getValueIsAdjusting(); if (!adjust2) { // Eğer seçim varsa JList list = (JList) listSelectionEvent.getSource(); selectionValuem = list.getSelectedValue(); if (selectionValuem == null) return; tiklanmisSepettekiYemek = selectionValuem; lblSeciliFiyat.setText(((Fiyatlandirilabilir)tiklanmisSepettekiYemek).getPrice() + " TL"); } } }; chooseList.addListSelectionListener(listSelectionListener); } return chooseList; } /** * This method initializes choosePane * * @return javax.swing.JScrollPane */ private JScrollPane getChoosePane() { if (choosePane == null) { choosePane = new JScrollPane(chooseList); choosePane.setBounds(new Rectangle(350, 266, 399, 177)); choosePane.setViewportView(getChooseList()); choosePane.setVisible(true); } return choosePane; } /** * This method initializes cikar * * @return java.awt.Button */ private Button getCikar() { if (cikar == null) { cikar = new Button(); cikar.setBounds(new Rectangle(642, 233, 107, 27)); cikar.setLabel("Sepetten Çıkar"); cikar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { if(tiklanmisSepettekiYemek == null) return; choose.removeElement(tiklanmisSepettekiYemek); fiyatHesapla(); } }); } return cikar; } /** * This method initializes iceriklist * * @return javax.swing.JList */ private JList getIceriklist() { if (iceriklist == null) { iceriklist = new JList(icerik); ListSelectionListener listSelectionListener = new ListSelectionListener() { public void valueChanged(ListSelectionEvent listSelectionEvent) { boolean adjust2 = listSelectionEvent.getValueIsAdjusting(); if (!adjust2) { // Eğer seçim varsa JList list = (JList) listSelectionEvent.getSource(); Object selectionValue = list.getSelectedValue(); if (selectionValue == null) return; Yemek menuY = (Yemek)selectionValue; lblSeciliFiyat.setText(menuY.getPrice() + " TL"); } } }; iceriklist.addListSelectionListener(listSelectionListener); } return iceriklist; } /** * This method initializes icerikPane * * @return javax.swing.JScrollPane */ private JScrollPane getIcerikPane() { if (icerikPane == null) { icerikPane = new JScrollPane(iceriklist); icerikPane.setBounds(new Rectangle(347, 141, 405, 87)); icerikPane.setViewportView(getIceriklist()); } return icerikPane; } /** * This method initializes siparisFiltre * * @return javax.swing.JComboBox */ private JComboBox getSiparisFiltre() { if (siparisFiltre == null) { siparisFiltre = new JComboBox(); siparisFiltre.setBounds(new Rectangle(17, 25, 223, 29)); } siparisFiltre.addItem("Tüm Siparişler"); siparisFiltre.addItem("Onay Bekleyenler"); siparisFiltre.addItem("Yolda Olanlar"); siparisFiltre.addItem("Yerine Ulaşmış Siparişler"); siparisFiltre.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { fillOrderBox(); } }); return siparisFiltre; } /** * This method initializes btnIptal * * @return java.awt.Button */ private Button getBtnIptal() { if (btnIptal == null) { btnIptal = new Button(); btnIptal.setBounds(new Rectangle(251, 456, 205, 28)); btnIptal.setLabel("Sipariş İptal"); btnIptal.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { if (o != null) { o.cancelOrder(); fillOrderBox(); } } }); } return btnIptal; } /** * This method initializes txtDetails * * @return java.awt.TextArea */ private TextArea getTxtDetails() { if (txtDetails == null) { txtDetails = new TextArea(); txtDetails.setBounds(new Rectangle(254, 60, 499, 87)); txtDetails.setEditable(false); } return txtDetails; } /** * This method initializes oyLezzet * * @return java.awt.Choice */ private Choice getOyLezzet() { if (oyLezzet == null) { oyLezzet = new Choice(); oyLezzet.setBounds(new Rectangle(320, 331, 227, 26)); } oyLezzet.add("(yok)"); oyLezzet.add("İyi"); oyLezzet.add("Orta"); oyLezzet.add("Kötü"); return oyLezzet; } /** * This method initializes oyFiyat * * @return java.awt.Choice */ private Choice getOyFiyat() { if (oyFiyat == null) { oyFiyat = new Choice(); oyFiyat.setBounds(new Rectangle(322, 359, 225, 21)); } oyFiyat.add("(yok)"); oyFiyat.add("İyi"); oyFiyat.add("Orta"); oyFiyat.add("Kötü"); return oyFiyat; } /** * This method initializes oyHiz * * @return java.awt.Choice */ private Choice getOyHiz() { if (oyHiz == null) { oyHiz = new Choice(); oyHiz.setBounds(new Rectangle(319, 387, 229, 21)); } oyHiz.add("(yok)"); oyHiz.add("İyi"); oyHiz.add("Orta"); oyHiz.add("Kötü"); return oyHiz; } /** * This method initializes btnMenuEkle * * @return java.awt.Button */ private Button getBtnMenuEkle() { if (btnMenuEkle == null) { btnMenuEkle = new Button(); btnMenuEkle.setBounds(new Rectangle(175, 109, 145, 29)); btnMenuEkle.setLabel("Menüyü Sepete Ekle"); btnMenuEkle.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { if(tiklanmisMenu == null) return; choose.addElement(tiklanmisMenu); fiyatHesapla(); } }); } return btnMenuEkle; } /** * This method initializes btnYemekEkle * * @return java.awt.Button */ private Button getBtnYemekEkle() { if (btnYemekEkle == null) { btnYemekEkle = new Button(); btnYemekEkle.setBounds(new Rectangle(179, 306, 143, 30)); btnYemekEkle.setLabel("Yemeği Sepete Ekle"); btnYemekEkle.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { if(tiklanmisYemek == null) return; choose.addElement(tiklanmisYemek); fiyatHesapla(); } }); } return btnYemekEkle; } /** * This method initializes btnSiparisVer * * @return java.awt.Button */ private Button getBtnSiparisVer() { if (btnSiparisVer == null) { btnSiparisVer = new Button(); btnSiparisVer.setBounds(new Rectangle(558, 477, 187, 40)); btnSiparisVer.setLabel("SİPARİŞ VER!"); btnSiparisVer.addActionListener(new java.awt.event.ActionListener() { @SuppressWarnings("unchecked") public void actionPerformed(java.awt.event.ActionEvent e) { Vector v = new Vector(); for(int i=0;i<choose.size();i++) { v.addElement(choose.elementAt(i)); } if(v.size() == 0) return; Order o = new Order(c, r, v); System.out.println(o); resetNewOrderWindow(); fillOrderBox(); } }); } return btnSiparisVer; } private void resetNewOrderWindow() { r = (Restaurant)restaurantBox.getSelectedItem(); if (r == null) return; oyy.setText(r.getOrtPuan() + " "); listofMenu.clear(); for (proje.restaurant.Menu m : r.getMenuler()) { listofMenu.addElement(m); } listOfFood.clear(); for (proje.restaurant.Yemek y : r.getYemekler()) { listOfFood.addElement(y); } choose.clear(); icerik.clear(); lblSeciliFiyat.setText(""); lblNormalFiyat.setText("Normal fiyat: 0 TL"); lblIndirimliFiyat.setText("Sizin ödeyeceğiniz: 0 TL"); } @SuppressWarnings("unchecked") private void fiyatHesapla() { double fiyat = 0; for(int i=0;i<choose.size();i++) { fiyat += ((Fiyatlandirilabilir)choose.getElementAt(i)).getPrice(); } fiyat = (double)((int)(fiyat * 100))/100; lblNormalFiyat.setText("Normal fiyat: " + fiyat + " TL"); Vector v = new Vector(); for(int i=0;i<choose.size();i++) { v.addElement(choose.elementAt(i)); } lblIndirimliFiyat.setText("Sizin ödeyeceğiniz: " + Order.askPrice(c, v) + " TL"); int t = c.getType(); String s = ""; switch (t) { case CONSTANT.SILVERCUSTOMER: s = "Slv"; break; case CONSTANT.GOLDCUSTOMER: s = "Gld"; break; case CONSTANT.URANIUMCUSTOMER: s = "Urny."; break; } lblIndirimliFiyat.setText(lblIndirimliFiyat.getText().concat(" (" + s + ")")); } /** * This method initializes tumRestoranlar * * @return javax.swing.JPanel */ private JPanel getTumRestoranlar() { if (tumRestoranlar == null) { GridBagConstraints gridBagConstraints = new GridBagConstraints(); gridBagConstraints.fill = GridBagConstraints.BOTH; gridBagConstraints.gridy = 0; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; gridBagConstraints.gridx = 0; tumRestoranlar = new JPanel(); tumRestoranlar.setLayout(new GridBagLayout()); tumRestoranlar.add(getAllrestList(), gridBagConstraints); } return tumRestoranlar; } /** * This method initializes allrestList * * @return java.awt.List */ private List getAllrestList() { if (allrestList == null) { allrestList = new List(); allrestList.setFont(new Font("Dialog", Font.PLAIN, 14)); } for(Restaurant r: Main.restaurants.sortSortableOnes(true)) { allrestList.add(r + " (" + r.getOrtPuan() + "/3.00) Adres: " + r.getAdress()); } return allrestList; } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | package proje.ui; import java.awt.Frame; import java.awt.Button; import java.awt.Rectangle; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import proje.restaurant.Restaurant; import proje.user.Customer; public class Common extends Frame { private static final long serialVersionUID = 1L; private Button previous = null; private Button firstbutton = null; private Button exit = null; private String object; private Restaurant res; private Customer cus; /** * This is the default constructor */ public Common(String ob, Restaurant r) { super(); initialize(); this.object = ob; this.res=r; } public Common(String ob, Customer c) { super(); initialize(); this.object = ob; this.cus=c; } /** * This method initializes this * * @return void */ private void initialize() { this.setLayout(null); this.setSize(465, 226); this.setResizable(false); this.setTitle("Yolunu belirle..."); this.add(getPrevious(), null); this.add(getFirstbutton(), null); this.add(getExit(), null); this.addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent e) { System.exit(0); } }); } /** * This method initializes previous * * @return java.awt.Button */ private Button getPrevious() { if (previous == null) { previous = new Button(); previous.setBounds(new Rectangle(28, 49, 115, 58)); previous.setLabel("Geri git"); previous.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { shut_up(); if (object == "Admin") { Admin ad = new Admin(); ad.setVisible(true); } else if (object == "Boss") { Boss bo = new Boss(res); bo.setVisible(true); } else if (object == "Client") { Client cli = new Client(cus); cli.setVisible(true); } } }); } return previous; } /** * This method initializes firstbutton * * @return java.awt.Button */ private Button getFirstbutton() { if (firstbutton == null) { firstbutton = new Button(); firstbutton.setBounds(new Rectangle(152, 151, 145, 52)); firstbutton.setLabel("Rol değiştir"); firstbutton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { shut_up(); Entry en = new Entry(); en.setVisible(true); } }); } return firstbutton; } /** * This method initializes exit * * @return java.awt.Button */ private Button getExit() { if (exit == null) { exit = new Button(); exit.setBounds(new Rectangle(316, 45, 109, 60)); exit.setLabel("Çek git :)"); exit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.exit(0); } }); } return exit; } public void shut_up() { this.setVisible(false); } } // @jve:decl-index=0:visual-constraint="0,25" |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 | package proje.ui; import java.awt.CheckboxGroup; import java.awt.Frame; import java.awt.Rectangle; import java.awt.Checkbox; import java.awt.Label; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import javax.swing.ImageIcon; import javax.swing.JLabel; import javax.swing.JButton; import java.awt.Color; import javax.swing.JComboBox; import proje.bootstrapper.Main; import proje.restaurant.Restaurant; import proje.user.Customer; import proje.user.User; import java.awt.Font; public class Entry extends Frame { private static final long serialVersionUID = 1L; private Checkbox adminBox = null; private Checkbox bossBox = null; private Checkbox clientBox = null; CheckboxGroup cbg = new CheckboxGroup(); private Label label3 = null; private JLabel image = null; private JButton jButton = null; int value; private JLabel bossImage = null; private JLabel adminImage = null; private JComboBox jComboBox = null; private JLabel jLabel = null; private Label label4 = null; private JComboBox nameBox = null; /** * This is the default constructor */ public Entry() { super(); initialize(); for (Restaurant r : Main.restaurants) { jComboBox.addItem(r); } jComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Restaurant res = (Restaurant) jComboBox.getSelectedItem(); System.out.println("seçilen restoran:" + res.getAdress()); } }); for (User u : Main.users.sortSortableOnes(true)) { if (u instanceof Customer) { nameBox.addItem(u); } } nameBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.out.println("seçilen kişi:" +(Customer)nameBox.getSelectedItem()); } }); } /** * This method initializes this * * @return void */ private void initialize() { label4 = new Label(); label4.setBounds(new Rectangle(397, 358, 114, 23)); label4.setVisible(false); jLabel = new JLabel(); jLabel.setBounds(new Rectangle(195, 361, 126, 22)); jLabel.setVisible(false); adminImage = new JLabel(); adminImage.setBounds(new Rectangle(313, 124, 145, 137)); adminImage.setIcon(new ImageIcon("ajdar.jpg")); bossImage = new JLabel(); bossImage.setBounds(new Rectangle(41, 347, 146, 140)); bossImage.setIcon(new ImageIcon("patron.jpg")); image = new JLabel(); image.setBounds(new Rectangle(585, 341, 148, 142)); image.setIcon(new ImageIcon("musteri.jpg")); label3 = new Label(); label3.setBounds(new Rectangle(12, 37, 272, 68)); label3.setFont(new Font("Dialog", Font.BOLD, 36)); label3.setText("Kimsiniz?"); this.setLayout(null); this.setSize(800, 600); this.setBackground(Color.white); this.setResizable(false); this.setTitle("Merhaba!"); this.add(getAdminBox(), null); this.add(getBossBox(), null); this.add(getClientBox(), null); this.add(label3, null); this.add(image, null); this.add(getJButton(), null); this.setVisible(true); this.add(bossImage, null); this.add(adminImage, null); this.add(getJComboBox(), null); this.add(jLabel, null); this.add(label4, null); this.add(getNameBox(), null); this.addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent e) { System.exit(0); // windowClosing() } }); } /** * This method initializes adminBox * * @return java.awt.Checkbox */ private Checkbox getAdminBox() { if (adminBox == null) { adminBox = new Checkbox(); adminBox.setBounds(new Rectangle(313, 98, 144, 19)); adminBox.setLabel("Yönetici"); adminBox.setCheckboxGroup(cbg); adminBox.setEnabled(true); adminBox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent arg0) { value = 1; label4.setVisible(false); nameBox.setVisible(false); jLabel.setVisible(false); jComboBox.setVisible(false); } }); } return adminBox; } /** * This method initializes bossBox * * @return java.awt.Checkbox */ private Checkbox getBossBox() { if (bossBox == null) { bossBox = new Checkbox(); bossBox.setBounds(new Rectangle(42, 320, 144, 18)); bossBox.setLabel("Operatör"); bossBox.setCheckboxGroup(cbg); bossBox.setEnabled(true); bossBox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent arg0) { jComboBox.setVisible(true); jLabel.setVisible(true); jLabel.setText("Lokantam:"); value = 2; label4.setVisible(false); nameBox.setVisible(false); } }); } return bossBox; } /** * This method initializes clientBox * * @return java.awt.Checkbox */ private Checkbox getClientBox() { if (clientBox == null) { clientBox = new Checkbox(); clientBox.setBounds(new Rectangle(585, 314, 147, 22)); clientBox.setLabel("Müşteri"); clientBox.setCheckboxGroup(cbg); clientBox.setEnabled(true); clientBox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent arg0) { label4.setVisible(true); label4.setText("Adım - Soyadım:"); nameBox.setVisible(true); jLabel.setVisible(false); jComboBox.setVisible(false); value = 3; } }); } return clientBox; } public void shut_up() { this.setVisible(false); } public boolean choosingControl() { if ((value == 1) || (value == 2) || (value == 3)) { return true; } else { shut_up(); Warning w = new Warning(); w.setVisible(true); return false; } } /** * This method initializes jButton * * @return javax.swing.JButton */ private JButton getJButton() { if (jButton == null) { jButton = new JButton(); jButton.setBounds(new Rectangle(637, 501, 134, 59)); jButton.setText("Evet, gerçekten."); jButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (choosingControl()) { if (value == 1) { shut_up(); Admin ad = new Admin(); ad.setVisible(true); } else if (value == 2) { doOpenBossWindow(); } else if (value == 3) { doOpenCustomerWindow(); } } } }); } return jButton; } private void doOpenBossWindow() { if (jComboBox.getSelectedItem() != null) { shut_up(); Boss b = new Boss((Restaurant) (jComboBox.getSelectedItem())); b.setVisible(true); } } private void doOpenCustomerWindow() { if (nameBox.getSelectedItem() != null) { System.out.println("Giden kişi: "+(Customer)(nameBox.getSelectedItem())); shut_up(); Client c = new Client((Customer)(nameBox.getSelectedItem())); c.setVisible(true); } } /** * This method initializes jComboBox * * @return javax.swing.JComboBox */ private JComboBox getJComboBox() { if (jComboBox == null) { jComboBox = new JComboBox(); jComboBox.setBounds(new Rectangle(195, 387, 194, 30)); jComboBox.setVisible(false); } return jComboBox; } /** * This method initializes nameBox * * @return javax.swing.JComboBox */ private JComboBox getNameBox() { if (nameBox == null) { nameBox = new JComboBox(); nameBox.setBounds(new Rectangle(397, 387, 182, 29)); nameBox.setVisible(false); } return nameBox; } } // @jve:decl-index=0:visual-constraint="10,9" |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | package proje.ui; import java.awt.Frame; import java.awt.Label; import java.awt.Rectangle; import java.awt.Button; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; public class Warning extends Frame { private static final long serialVersionUID = 1L; private Label label = null; private Label label1 = null; private Label label2 = null; private Label label3 = null; private Button okbutton = null; private Button baybaybutton = null; /** * This is the default constructor */ public Warning() { super(); initialize(); } /** * This method initializes this * * @return void */ private void initialize() { label3 = new Label(); label3.setBounds(new Rectangle(31, 210, 428, 30)); label3.setText("Yok, vazgeçtim, anladım ki hata bulamayacağım diyorsan Bay Bay'a bas :))"); label2 = new Label(); label2.setBounds(new Rectangle(29, 164, 325, 32)); label2.setText("Rol seçimine dönmek için '>>'a bas."); label1 = new Label(); label1.setBounds(new Rectangle(30, 114, 324, 35)); label1.setText("Gerçekten böyle bir hatayı yakalayamayacak mıydık yani?"); label = new Label(); label.setBounds(new Rectangle(29, 60, 324, 36)); label.setText("Ne yani? :))"); this.setLayout(null); this.setSize(527, 287); this.setTitle("Uyarı! Warning! die Warnung!"); this.add(label, null); this.add(label1, null); this.add(label2, null); this.add(label3, null); this.add(getOkbutton(), null); this.add(getBaybaybutton(), null); this.addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent e) { System.exit(0); // windowClosing() } }); } /** * This method initializes okbutton * * @return java.awt.Button */ private Button getOkbutton() { if (okbutton == null) { okbutton = new Button(); okbutton.setBounds(new Rectangle(389, 60, 105, 47)); okbutton.setLabel(">>"); okbutton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { shut_up(); Entry en = new Entry(); en.setVisible(true); } }); } return okbutton; } /** * This method initializes baybaybutton * * @return java.awt.Button */ private Button getBaybaybutton() { if (baybaybutton == null) { baybaybutton = new Button(); baybaybutton.setBounds(new Rectangle(388, 122, 106, 48)); baybaybutton.setLabel("Bay Bay!"); baybaybutton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { shut_up(); } }); } return baybaybutton; } public void shut_up() { this.setVisible(false); } } // @jve:decl-index=0:visual-constraint="7,4" |
1 2 3 4 5 6 7 8 9 10 11 12 | package proje.user; public final class Administrator extends User { public Administrator(String firstName, String lastName) { super(firstName,lastName); } public void changeCustomerType(Customer c, int type){//c müşterisinin tipini type ile değiştirir. c.changeType(type); } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | package proje.user; import java.util.Date; import java.util.Vector; import proje.bootstrapper.Main; import proje.restaurant.Order; import proje.util.CONSTANT; import proje.util.SortableList; @SuppressWarnings("unchecked") public class Customer extends User implements Comparable { private String adress; private boolean gender; private String lookLike; /* Müşterinin tipi */ private SortableList<Order> orders = new SortableList<Order>(); /* Şimdiye kadarki tüm siparişleri, */ private int type = CONSTANT.SILVERCUSTOMER; private boolean isTypeCheckingAutomated = true; // Constructors public Customer(String firstName, String lastName, String adress, boolean gender, String lookLike) { this(firstName, lastName, adress,gender,lookLike,CONSTANT.AUTO); } /** * Yeni bir müşteri yaratılır. Müşteri tipi olarak CONST.AUTO dışında bir değer girilirse, * sistem bunu müşteri tipi değişiminin manuel yapılacağı olarak algılar ve sipariş sayısı kontrolü yapmaz. * * Eğer tip değişiminin sistem tarafından otomatik yapılması isteniyorsa CONST.AUTO değeri kullanılmalıdır! * * @param firstName * @param lastName * @param adress * @param gender * @param lookLike * @param musteriTipi */ public Customer(String firstName, String lastName, String adress, boolean gender, String lookLike, int musteriTipi) { super(firstName, lastName); this.adress = adress; this.gender = gender; this.lookLike = lookLike; this.type = (musteriTipi > 0 ? musteriTipi : CONSTANT.SILVERCUSTOMER); if (musteriTipi > 0) { this.isTypeCheckingAutomated = false; } } // Getter ve Setter mehtodlar public String getAdress(){ return this.adress; } public boolean getGender(){ return this.gender; } public String getLooklike(){ return this.lookLike; } public void setAdress(String adress){ this.adress=adress; } public void setGender(boolean gender){ this.gender=gender; } public void setLooklike(String lookLike){ this.lookLike=lookLike; } public int getTotalOrderCount() { return this.orders.size(); } public int getType() { return type; } /** * Kullanıcının verdiği son siparişin tarihini döndürür. Kullanıcı hiç sipariş vermediyse null * döner. * @return Date */ public Date getLastOrderTime () { this.orders.sortSortableOnes(true); return (this.orders.size() > 0 ? this.orders.elementAt(0).getOrderTime() : null); } /*** * Kullanıcının bıraktığı son yorumları gösterir. Eğer kullanıcı istenen sayıdan daha az sayıda yorum bırakmışsa * vektörün eleman sayısı istenenden az olabilir. * @param Kaç tane yorum isteniyor * @return Vektör içinde String yorumlar */ public Vector<String> getLastCommentsUserWrote(int howMany) { if (howMany < 0) { howMany = 1; } Vector<String> ret = new Vector<String>(); System.out.println("ABOOO:"); int i = 0; this.orders.sortSortableOnes(true); System.out.println(this.orders.size()); while (i < howMany) { try { System.out.println(this.orders.elementAt(i).getComment()); /* Sistemde istenen sayıda yoksa çökmesin */ if (this.orders.elementAt(i).getComment() != null) { System.out.println("OHAA: " + this.orders.elementAt(i).getComment()); ret.add(this.orders.elementAt(i).getComment()); } } catch (ArrayIndexOutOfBoundsException e) { System.out.print(e.getMessage()); break; } i++; } return ret; } public int getTotalVoteCount() { int i = 0; for(Order o: this.orders) { if (o.isUserVotedForThisOrder()) i++; } return i; } /** * Nesneye bağlı tüm siparişleri bir SortableList içerisinde tarihe göre * azalan sırada gönderir. * @return Vektör içerisinde Order */ public SortableList<Order> getAllOrdersByCurrentUserSortedByDateDESC() { return this.orders.sortSortableOnes(true); } public void changeType(int newType) { /* Admin değiştiriyorsa */ if (newType == CONSTANT.AUTO) { /* Müşterinin tipini upgrade edecek miyiz? */ if(this.getTotalOrderCount() < CONSTANT.GOLDCUSTOMERLIMIT) { newType = CONSTANT.SILVERCUSTOMER; } else if (this.getTotalOrderCount() < CONSTANT.URANIUMCUSTOMERLIMIT){ newType = CONSTANT.GOLDCUSTOMER; } else { newType = CONSTANT.URANIUMCUSTOMER; } } changeType(newType, false); } public boolean changeType(int newType, boolean auto) { /* Sistem değiştiriyorsa */ this.isTypeCheckingAutomated = auto; if (!(newType==CONSTANT.SILVERCUSTOMER || newType == CONSTANT.GOLDCUSTOMER || newType == CONSTANT.URANIUMCUSTOMER)) { return false; } this.type = newType; return true; } public boolean getIsTypeCheckingAutomated () { return this.isTypeCheckingAutomated; } public void newOrder(Order o) { this.orders.add(o); } public void cancelOrder(Order o){ if(o.cancelOrder()==true){ o.killOrder(); orders.remove(o); } } public int compareTo (Object o) { if (!(o instanceof Customer)) { throw new ClassCastException(); } return this.getTotalOrderCount() - ((Customer)o).getTotalOrderCount(); } /* Kullanıcıyı öbür dünyaya gönderir. Kullanıcının yarattığı tüm bilgiler de sistemden cıncıklanır. */ public void deleteUser() { while (this.orders.size() != 0) { this.orders.firstElement().killOrder(); } Main.users.remove(this); System.gc(); } /* Hiçbir kontrol yapmadan siparişi kullanıcıdan siler. */ public void killOrder(Order o) { this.orders.remove(o); } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | package proje.user; import proje.restaurant.Restaurant; public final class Operator extends User { private Restaurant sorumluOldRest; /* Operatörün sorumlu olduğu restoran */ public Operator(String firstName, String lastName) { super(firstName,lastName); } public void setSormluOldRestoran(Restaurant r) { this.sorumluOldRest = r; } public Restaurant getSormluOldRestoran() { return this.sorumluOldRest; } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | package proje.user; import proje.bootstrapper.Main; public abstract class User { /* Genel Bilgiler */ private String firstName = null; private String lastName = null; public User(String firstName, String lastName) { this.firstName = firstName; this.lastName = lastName; Main.users.add(this); } public String getFirstName() { return this.firstName; } public String getLastName() { return this.lastName; } public void setFirstName(String name) { this.firstName = name; } public void setLastName(String name) { this.lastName = name; } @Override public String toString() { return firstName + " " + lastName; } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | package proje.util; public class CONSTANT { public static final boolean MALE = false; public static final boolean FEMALE = true; public static final int NEWORDER = 0; public static final int ORDERINPROGRESS = 1; public static final int DELIVEREDORDER = 2; /* GOLD VE URANYUM MÜŞTERİ OLMAK İÇİN GEREKLİ SİPARİŞ LİMİTLERİ */ public static final int GOLDCUSTOMERLIMIT = 5; public static final int URANIUMCUSTOMERLIMIT = 7; /* GOLD VE URANYUM MÜŞTERİLERE UYGULANAN İNDİRİM YÜZDELERİ */ public static final int GOLDCUSTOMERDISCOUNT = 5; public static final int URANIUMCUSTOMERDISCOUNT = 30; public static final int URANIUMCUSTOMER = 92; public static final int GOLDCUSTOMER = 79; public static final int SILVERCUSTOMER = 47; public static final int AUTO = -1; } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | package proje.util; import proje.user.Customer; @SuppressWarnings("unchecked") public class CustomerOfARestaurant implements Comparable { public int number = 1; public Customer c; public CustomerOfARestaurant (Customer c) { this.c = c; } @Override public int compareTo(Object o) { CustomerOfARestaurant c = (CustomerOfARestaurant)o; return number - c.number; } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | package proje.util; import java.util.Vector; public class QuickSort { @SuppressWarnings("unchecked") private static void qsort(Vector a, int lo0, int hi0) { int lo = lo0; int hi = hi0; if ( hi0 > lo0) { Comparable mid = ((Comparable)a.elementAt(( lo0 + hi0 ) / 2 )); while ( lo <= hi ) { while (( lo < hi0 ) && (((Comparable)a.elementAt(lo)).compareTo(mid) < 0 )) ++lo; /* find an element that is smaller than or equal to * the partition element starting from the right Index. */ while (( hi > lo0 ) && (((Comparable)a.elementAt(hi)).compareTo(mid) > 0 )) --hi; // if the indexes have not crossed, swap if ( lo <= hi ) { swap(a, lo, hi); ++lo; --hi; } } /* If the right index has not reached the left side of array * must now sort the left partition. */ if ( lo0 < hi ) qsort( a, lo0, hi ); /* If the left index has not reached the right side of array * must now sort the right partition. */ if ( lo < hi0 ) qsort( a, lo, hi0 ); } } @SuppressWarnings("unchecked") private static void swap(Vector a, int i, int j) { Object temp = a.elementAt(i); a.setElementAt(a.elementAt(j), i); a.setElementAt(temp, j); } @SuppressWarnings("unchecked") public static void sort(Vector a) { /* Dikkat! Bu sınıf, gönderilen sınıf üzerinde sıralamayı yapar. Kopya oluşturmaz. */ qsort(a, 0, a.size() - 1); } } |
1 2 3 4 5 6 | package proje.util; interface Reversible { /* Nesenin sıralamasını tersine çevirir. */ public void reverse(); } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | package proje.util; import java.util.Vector; public final class SortableList<T> extends Vector<T> implements Reversible{ private static final long serialVersionUID = 8057198066604379599L; public SortableList() { super(); } public SortableList<T> sortSortableOnes() { return sortSortableOnes(false); } /*** * Listedeki sıralanabilir ögeleri (Comparable) ile sıralar. Bu arayüzü implement etmeyen * sıralanamaz nesneleri en sona ekler. Listenin <b>kendisisi de sıralanmış olduğu gibi</b> * aynı zamanda kendi referansını da döndürür. * * @param descending: Azalan sırada mı sıralansın? * @return Sıralı Liste */ public SortableList<T> sortSortableOnes(boolean descending) { SortableList<T> sonuc = new SortableList<T>(); for (T in: this) { if (in instanceof Comparable) { sonuc.add(in); } } QuickSort.sort(sonuc); if (descending) { sonuc.reverse(); } for (T in: this) { if (!(in instanceof Comparable)) { sonuc.add(in); } } this.clear(); this.addAll(sonuc); return this; } public void reverse() { SortableList<T> temp = new SortableList<T>(); for (int i = this.size()-1; i >= 0;i--) { temp.add(this.elementAt(i)); } this.clear(); this.addAll(temp); } } |
Twitler yükleniyor... 5 saniye sonra
Bıdı bıdı bıdı bıdı dıdı dıdı dudu dudu hıdı hıdı hödü hödü yüklüyoruz öhüm öhüm bıdı bıdı vs vs... 6 nanosaniye önce
Yüklenmenin geç olmasının sebebi ben değilim, Twitter API'sinin yavaş olması. Gudu gudu hıdı hödö büdü büdü... 25697 asır önce
Ha tabi bunları okumuşsan, bu sitenin çok gizli bir özelliğini bulmuşsun demektir. ;) Tebrikler. Bu "sürpiz yumurta"yı bulduğunu bana da haber verir misin? Tıkla! 6 dinazor önce
Projeyi hangi ide ortaminda açabiliriz, eclipse te tanimadi.
@Mutkan: Eclipse, NetBeans ya da JAVA için geliştirilmiş herhangi bir IDE’de açabilirsiniz. Eclipse tanımıyorsa başka bir problem var demektir, çünkü projenin çok büyük bir kısmını bizzat biz Eclipse’de geliştirdik.
S.a siteni google aramasında gördüm.ara sıra kontrol ediyorum ne var ne yok diye.Ayrıca siten oldukça hoş.Yaptıklarını takdir ediyor,başarılarının devamını diliyorum.
Umut ,Eclipse de tanımamasının nedeni galiba senin kodun 64 bitlik bir işletim siteminde yazılmış olması.çünkü ege lab’daki bilgisayarlarda açmak istedim açmamadı ve “32 bitlik bir java uygulaması değil”diye bir hata verdi.hatalıysam cevaplayın
@Ckart: Bir problem var, çünkü o kod 64-bit’e özgü herhangi bir şey içermiyor. Kodun doğrudan Eclipse’de çalışmamasının nedeni, projenin NetBeans projesi yapısında oluşturulmuş olması olabilir. Onun dışında 32-bitlik bir Java uygulamasıdır hatasını bilemiyorum. Derlenmiş halini (jar dosyasını) doğrudan çalıştırmayı açıkçası hiç denemedim.