לוגו אתר Fresh          
 
 
  אפשרות תפריט  ראשי     אפשרות תפריט  צ'אט     אפשרות תפריט  מבזקים     אפשרות תפריט  צור קשר     חץ שמאלה ‎print ‎"Hello World!"; if‎ ‎not rules.‎know ‎then rules.‎read(); חץ ימינה  

לך אחורה   לובי הפורומים > מחשבים > תכנות ובניית אתרים
שמור לעצמך קישור לדף זה באתרי שמירת קישורים חברתיים
תגובה
 
כלי אשכול חפש באשכול זה



  #1  
ישן 07-11-2008, 03:45
  c4designer c4designer אינו מחובר  
 
חבר מתאריך: 22.10.08
הודעות: 15

ציטוט:
במקור נכתב על ידי דור
כבר ענו לך...


הינה התקדמות קטנה:
קוד:
//p.361 #1 import hsa.PhoneBook; import hsa.Stdin; public class BetterPhoneBook { public static void main (String[] args) { PhoneBook book; int command; book = new PhoneBook (); System.out.println ("Enter a command"); System.out.println (" 0 - Quit"); System.out.println (" 1 - Add an entry"); System.out.println (" 2 - Look up and entry"); System.out.println (" 3 - Remove an entry"); System.out.println (" 4 - Edit an entry"); System.out.print ("Command: "); command = Stdin.readInt (); // Loop while (command != 0) { if (command == 1) { // Add entry. String name, phone, personName; int a, i; System.out.print ("Enter new name: "); name = Stdin.readLine (); personName = book.lookUp (name); a = personName.length (); for (i = 1; i <= a; i++) { if (a == 0) { System.out.print ("error"); break; } } System.out.print ("Enter phone number: "); phone = Stdin.readLine (); book.add (name, phone); System.out.println ("Added " + name + " to the phone book"); } // if (command == 1) else if (command == 2) { // Look up entry. String name, phone; System.out.print ("Enter name: "); name = Stdin.readLine (); phone = book.lookUp (name); if (phone.length () == 0) { System.out.println (name + " was not found " + "in phone book"); } else { System.out.println (name + "'s phone " + "number is " + phone); } } // if (command == 2) else if (command == 3) { // Delete entry. String name, phone; System.out.print ("Enter name to be deleted: "); name = Stdin.readLine (); phone = book.lookUp (name); if (phone.length () == 0) { System.out.println (name + " was not found " + "in phone book"); } else { book.remove (name); System.out.println (name + " is deleted"); } } // if (command == 3) else if (command == 4) { // Edit entry. String name, phone; System.out.print ("Enter name to be edited: "); name = Stdin.readLine (); phone = book.lookUp (name); if (phone.length () == 0) { System.out.println (name + " was not found " + "in phone book"); } else { System.out.print ("Enter new phone number: "); phone = Stdin.readLine (); book.remove (name); book.add (name, phone); System.out.println (name + "'s phone " + "number is now " + phone); } } // if (command == 4) else { System.out.println ("Illegal command. Command"); System.out.println ("must be from 0 to 4"); } // else // Prompt user and read the command. System.out.print ("Command: "); command = Stdin.readInt (); } // while (command != 0) } }


זה לא אומר "שגיאה" שמכניסים את אותו השם פעם שנייה.
למה?
תגובה ללא ציטוט תגובה עם ציטוט חזרה לפורום
תגובה

כלי אשכול חפש באשכול זה
חפש באשכול זה:

חיפוש מתקדם
מצבי תצוגה דרג אשכול זה
דרג אשכול זה:

מזער את תיבת המידע אפשרויות משלוח הודעות
אתה לא יכול לפתוח אשכולות חדשים
אתה לא יכול להגיב לאשכולות
אתה לא יכול לצרף קבצים
אתה לא יכול לערוך את ההודעות שלך

קוד vB פעיל
קוד [IMG] פעיל
קוד HTML כבוי
מעבר לפורום



כל הזמנים המוצגים בדף זה הם לפי איזור זמן GMT +2. השעה כעת היא 18:39

הדף נוצר ב 0.05 שניות עם 11 שאילתות

הפורום מבוסס על vBulletin, גירסא 3.0.6
כל הזכויות לתוכנת הפורומים שמורות © 2024 - 2000 לחברת Jelsoft Enterprises.
כל הזכויות שמורות ל Fresh.co.il ©

צור קשר | תקנון האתר