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

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



  #1  
ישן 09-06-2007, 20:26
  ChaosINC ChaosINC אינו מחובר  
 
חבר מתאריך: 06.05.07
הודעות: 4
שימוש בשיטת Isvalid ב Java

אני בונה תוכנית בעזרת שלוש מחלקות: Passport, Traveler, Data
בשלב הזה אני סיימתי את מחלקת Date ומנסה ליישם שיטה במחלקת Passport שתאמת אם הדרכון תקף בתאריך הנתון ואני מחפש דרך לממש את השיטה דרך ה Date למישהו יש רעיון איך אני ממשיך משם?





קוד:
public class Passport { private int _number; private Date _expiryDate; private String _name; /** * * Constructor for objects of class Passport Constructs a passport given an passport number, name, and expiry date for a passport */ public Passport ( int number, String name, Date expiryDate ) { if (name==null || expiryDate==null) System.out.println("illegal passport # sent to set SetDate"); else { _expiryDate= new Date (expiryDate); _name= new String (name); } } /** * Constructor for objects of class passport * Copy constructor */ public Passport (Passport other) { if (other==null) System.out.println("illegal passport sent to copy consturctor"); else { this._number = other._number; this._expiryDate = new Date (other._expiryDate); this._name = new String (other._name); } } /** * The method returns with passport # */ public int getNumber() { return this. _number; } /** * The operation returns with a name */ public String getName() { return this._name; } /** * The method returns with expiry date */ public Date getExpiryDate() { return this._expiryDate; } public void setName (String name) { if (name==null) System.out.println("illegal name sent to setName"); else name = new String (_name); } public void setExpiryDate (Date newExpDate) { if (newExpDate==null) System.out.println("illegal expiry date sent to setName"); else newExpDate = new Date (newExpDate); } public boolean isValid (Date dateChecked) {

תגובה ללא ציטוט תגובה עם ציטוט חזרה לפורום
  #3  
ישן 09-06-2007, 22:38
  ChaosINC ChaosINC אינו מחובר  
 
חבר מתאריך: 06.05.07
הודעות: 4
בתגובה להודעה מספר 2 שנכתבה על ידי scripter שמתחילה ב "תשווה את תאריך התוקף של..."

אני אמור להשוות את התאריך עם ה class Date שכבר בניתי.
לא לבנות אובייקטים חדשים.

קוד:
public class Date { private int _day; private int _month; private int _year; //constructors: /** * creates a new Date object * @param _day the day in the month(1-31) * @param _month the month in the year * @param _year the year (in 4 digits) */ public Date(int day, int month, int year) { _day = day; _month = month; _year = year; } /** * Copy Constructor * @param passport to be copied */ public Date(Date date){ _day = date._day; _month = date._month; _year = date._year; } /** gets the year */ public int getYear(){ return _year; } /** gets the month */ public int getMonth(){ return _month; } /** gets the Day */ public int getDay(){ return _day; } /** sets the year * @param yearToSet the value to be set */ public void setYear(int yearToSet){ _year = yearToSet; } /** set the month * @param monthToSet the value to be set */ public void setMonth(int monthToSet){ _month = monthToSet; } /** sets the day * @param dayToSet the value to be set */ public void setDay(int dayToSet){ _day = dayToSet; } /** * checks if this date comes before a given date * @param date2 the given date * @retun true if this date comes before date2 */ public boolean before(Date date2) { if (_year < date2._year) return true; if (_year == date2._year) { if (_month < date2._month) return true; if (_month == date2._month && _day < date2._day) return true; } return false; } /** * @return String that represents this date * in the following format: * day.month.year (30.9.1917) */ public String toString() { return _day +"/" + _month + "/" + _year; } }
תגובה ללא ציטוט תגובה עם ציטוט חזרה לפורום
תגובה

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

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

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

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



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

הדף נוצר ב 0.04 שניות עם 12 שאילתות

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

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