java program need help!
I need to do my assingmnet for class. If any one know how to help me i would appreciate it a lot. This is my assingment:
Write a class to represent a time interval named ElapsedTime. This class represents elapsed time in days hours and minutes. It might be used by a shipping company to estimate and keep track od how long their vessels are at sea. If trip takes 7 1/2 days, elapsed time would be 7 days 12 hours and 0 minutes. Represent the current time interval as a number of minutes, stored in an int Java variable.
Constructor : ElapsedTime (int days, int hours int minutes)
This creates an object of the ElapsedTime class whose instance data is initialized according to the parameters of the constructor. For example, if the invocation of the constructor is ElapsedTime (0, 0, 0) an object is created representing a time interval of zero minutes. You may assume that all three arguments are never negative.
void setTime (int days int hours int minutes)
setTime() sets the current time interval according to its arguments. For example if the method invocation is setTime (7, 3,22) the time interval is 10,282 minutes. All three arguments are never negative.
void addTime (int days, hours minutes)
addTime adds to the objects current time interval according to its arguments.For example if the method invocation si addTime (1,0,0) the time interval is incresed by 1440 minutes. One or all of the arguments may be negative or zero.
Use the class Math.abs to make sure your instance data is always non-negative.
getDays returns the number of days not exceeded by the current time interval. This is never negative. For example if the current time is 1439 minutes getDays will return 0.
getHours returns number of hours in the current time interval after all whole days are taken out. This is never negative and never exceeds 23.
getMinutes returns the number of minutes in the current time interval after all whole days and all whole hours are taken out. This is never negative and never exceeds 59.
to String returns a String object representing the current time interval in days hours and minutes. THe form of the String shuld be days, hours, minutes where days is at least one digit, hours is always two digit between 00 and 23 and minutes two digits between 00 and 59. You can use Decimal Format class with a pattern of "00" to force a number to be represented by a string with a leading zero.
Write a test program to test the ElapsedTime class. The program shuld be written as a seperate class that instantiates an ElapsedTime object and calls its methods. In the test program, test each method with arguments supplied by your program to see if it works. For each test, use JOptionPane.showMessageDialog() to output what the test is what the results are and what was expected.
PLEASE IF ANYONE KNOW HOW TO DO THIS HELP ME!
By SlickWilly440 in forum Java
Last Post: 01-28-2006, 10:17 PM
By Rob Abbe in forum Talk to the Editors
Last Post: 01-13-2003, 03:57 PM
By Lori Piquet in forum Talk to the Editors
Last Post: 10-10-2002, 07:01 AM
By Glen Kunene in forum Talk to the Editors
Last Post: 03-23-2002, 01:43 AM
Last Post: 11-16-2000, 01:45 AM
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center