Results 1 to 2 of 2
- 04-12-2012, 05:52 PM #1
Member
- Join Date
- Apr 2012
- Posts
- 15
- Rep Power
- 0
custom made up date class with calendar
Hallo
Below is the Rentable class where i have some trouble with assigning some fields
first i need three dates the default date , a return date , and the service date --
in the code bellow vServiceDate in the constructor has that value - is it possible to create a new field and get that value from like what i did .
The next is can i assign a calendar to show the default date
basically i have trouble in how to compare the three fields i need
thanks for all the help
Java Code:public class RentableCar extends Car implements Rentable { public Date defaultDate; public Date returnDate; public Date newSdate; /** * Constructor for objects of class RentableCar */ public RentableCar(String vCode , String vHomeDepot , String vMake , Date vServiceDate , String newFuel , int newEngineSize , int Trans , Date newDefaultDate , Date newReturnDate ) { super(vCode , vHomeDepot , vMake , vServiceDate , newFuel , newEngineSize , Trans); defaultDate = newDefaultDate; returnDate = newReturnDate; newSdate = vServiceDate; } public boolean pickUp(Date d) { return true; } public boolean isRented(){ if(( returnDate != newSdate ) && (returnDate != defaultDate)) { return false; } else { return true; } } public Date getReturnDate(){ return defaultDate; } public void dropOff(){ } }Last edited by JosAH; 04-12-2012 at 06:03 PM. Reason: changed [quote] ... [/quote] tags to [code] ... [/code] tags
- 04-12-2012, 06:42 PM #2
Re: custom made up date class with calendar
When comparing Objects, don't use == or !=. Use the .equals() method instead. The == operator tests whether two Objects are the same instance. The .equals() method tests for semantic equality.
How to Ask Questions the Smart Way
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
Similar Threads
-
Help with date compare in calendar
By aksis in forum New To JavaReplies: 1Last Post: 12-01-2011, 08:48 PM -
Manually setting a date using Calendar and Date
By ravl13 in forum New To JavaReplies: 3Last Post: 10-25-2011, 11:12 PM -
Creating a Gregorian Calendar using a Date object gives date - 1
By prachi_goliwadekar in forum New To JavaReplies: 1Last Post: 05-08-2008, 08:32 PM -
java Date and Calendar
By valoyivd in forum New To JavaReplies: 1Last Post: 03-30-2008, 06:49 PM -
Calendar.DATE
By mew in forum New To JavaReplies: 1Last Post: 01-04-2008, 07:51 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks