MOON ROSE
04-11-2006, 11:22 PM
هلا شخباركم
انا اليوم اول مره اطلب منكم هالشيء بس شسوي المشكله اني جيت متاخره الدوام والحين مضيعه والدكتور يبينا انقدم برنامج اليوم وانا درست وحاله ولكن مافهمت للحين شلون اسويه لانه مخربطه معلوماتي بين السي والجافا للحين مافهمت
الله يخليكم ساعدوني فيه وصدق انا عضوه جديده بس والله مضطره ساعدوني والي يعافيكم
//References, null References, Objects and garbage Objects
//reference:is a varaible that is used to point to objects.
//Account a;
//Account b = new Account(1,"aa",900);
//a and b are references to point to account objects.
//
what is the difference between a and b?
//// a points to nothing(null)
//// b points to object
////
null reference:is a reference that refers to nothing
////
a.deposit(100);//Error
//// b.deposit(90); //Correct
/////
////Garbage object: is the object that has no references point to it
// Garbage Collector:
is a program that runs automatically by the runtime
//environment . search and remove garbage objects from the memory
//
Reference Assignment and Equality
class Time{
private int hour,min,sec;
public Time()**
setTime(0,0,0);
}
public Time(int h)**
setTime(h,0,0);
}
public Time(int h, int m)**
setTime(h,m,0);
}
public Time(int h, int m,int s)**
setTime(h,m,s);
}
public Time(Time time)**
setTime(time.hour,time.min,time.sec);
}
public void setTime(int h, int m, int s)**
setHour(h);
setMin(m);
setSec(s);
}
public void setHour(int h)**
hour=0;
if(h>=0&&h<24)
hour = h;
}
public void setMin(int m)**
min = (m>=0&&m<60?m:0);
}
public void setSec(int s)**
sec = (s>=0&&s<60?s:0);
}
public int getHour(){return hour;}
public int getMin(){return min;}
public int getSec(){return sec;}
public boolean equals(Time t)
**
if(hour==t.hour&&min==t.min&&sec==t.sec)
return true;
else
return false;
}
public String toUniversalTime()**
return hour+ " : " + min +" : "+ sec +"\n";
}
}
///Complete the above Time class
/* 1.add method tec() which will increase the time by one second
note that after 60 seconds one min sould be increased
after 60 min one hour should be increased
no hour greater than 23
2. toString method which returns a string contains the time
in the format of am,pm
3. create a class(main) to test the time
1.create 3 time objects
2.display the times in universal time
3.call the tec method 1000 times for the 1st object
4. display the times in the am,pm format
انا اليوم اول مره اطلب منكم هالشيء بس شسوي المشكله اني جيت متاخره الدوام والحين مضيعه والدكتور يبينا انقدم برنامج اليوم وانا درست وحاله ولكن مافهمت للحين شلون اسويه لانه مخربطه معلوماتي بين السي والجافا للحين مافهمت
الله يخليكم ساعدوني فيه وصدق انا عضوه جديده بس والله مضطره ساعدوني والي يعافيكم
//References, null References, Objects and garbage Objects
//reference:is a varaible that is used to point to objects.
//Account a;
//Account b = new Account(1,"aa",900);
//a and b are references to point to account objects.
//
what is the difference between a and b?
//// a points to nothing(null)
//// b points to object
////
null reference:is a reference that refers to nothing
////
a.deposit(100);//Error
//// b.deposit(90); //Correct
/////
////Garbage object: is the object that has no references point to it
// Garbage Collector:
is a program that runs automatically by the runtime
//environment . search and remove garbage objects from the memory
//
Reference Assignment and Equality
class Time{
private int hour,min,sec;
public Time()**
setTime(0,0,0);
}
public Time(int h)**
setTime(h,0,0);
}
public Time(int h, int m)**
setTime(h,m,0);
}
public Time(int h, int m,int s)**
setTime(h,m,s);
}
public Time(Time time)**
setTime(time.hour,time.min,time.sec);
}
public void setTime(int h, int m, int s)**
setHour(h);
setMin(m);
setSec(s);
}
public void setHour(int h)**
hour=0;
if(h>=0&&h<24)
hour = h;
}
public void setMin(int m)**
min = (m>=0&&m<60?m:0);
}
public void setSec(int s)**
sec = (s>=0&&s<60?s:0);
}
public int getHour(){return hour;}
public int getMin(){return min;}
public int getSec(){return sec;}
public boolean equals(Time t)
**
if(hour==t.hour&&min==t.min&&sec==t.sec)
return true;
else
return false;
}
public String toUniversalTime()**
return hour+ " : " + min +" : "+ sec +"\n";
}
}
///Complete the above Time class
/* 1.add method tec() which will increase the time by one second
note that after 60 seconds one min sould be increased
after 60 min one hour should be increased
no hour greater than 23
2. toString method which returns a string contains the time
in the format of am,pm
3. create a class(main) to test the time
1.create 3 time objects
2.display the times in universal time
3.call the tec method 1000 times for the 1st object
4. display the times in the am,pm format