Posted by: Slackdemic September 14, 2006
Java Programming Help!
Login in to Rate this Post:     0       ?        
Maybe few people here know that I had a problem with JDK and JCreator. Because it took several days before I could successfully compile a simple java program, I didn't get to practice as I am supposed to. Anyway, I have a project to work on. I am kinda lost here because I am not sure where to start. To get this program done, I have divided this into three phases. If some Java people can direct me to get started for the phase I, I would be amply rewarded Here's what I've to do: Purpose: To write a class for a Date Object and a Class that will test the Date Class. DATE CLASS DESCRIPTION The object will include three properties, month, day and year as instance variables. Include two constructors in your class. A default constructor which initializes all instance variables to zero and a constructor which initializes the instance variables with parameter values passed to the constructor. On this assignment you may assume the values provided are correct…you do not have to provide error detection. Provide the following methods. 􀂃 set and get methods for each of the instance variables. 􀂃 a method to add a specified number of days based on a parameter value passed to the method. 􀂃 a method to add a specified number of months based on a parameter value passed to the method. 􀂃 a method to add a specified number of years based on a parameter value passed to the method. 􀂃 a toString () that will print the date in the following format mm/dd/yyyy TESTDATE CLASS DESCRIPTION Create a TestDate class which will test your Date class by doing the following. 􀂃 Create a default Date Object 􀂃 Create a Date Object with a valid day, month, year (use your birthday) 􀂃 Print the Date Objects before any modifications to the objects have been made 􀂃 Set the day, month and year on the default Date Object using set methods 􀂃 Add days to the birthdate Date Object to test the addDay method 􀂃 Add months to the birthdate Date Object to test the addMonth method 􀂃 Add years to the birthdate Date Object to test the addYear method 􀂃 Print the Date Objects after modifications 􀂃 Print the days, month, and year of a Date Object with the get methods. PHASES Phase I: Date class will calculate not be concerned with valid dates after adding days and months. Phase II: Your Date class will calculate valid dates after adding days and months but will not be concerned with leap year. Phase III: Your Date class will calculate valid dates for each year. OBJECTIVES 􀂃 Demonstrate ability to declare a class and use it to create an object 􀂃 Demonstrate ability to declare methods in a class to implement the class behaviors 􀂃 Demonstrate ability to declare instance variables to implement class attributes 􀂃 Demonstrate ability to use a constructor to ensure an object’s data is initialized when the object is created 􀂃 Demonstrate ability to use problem-solving techniques 􀂃 Demonstrate ability to use if and if…else selection statements. 􀂃 IF: o Birthday is 9/30/1986 o Default date was set to 6/26/1960 o One day is added to birthday Date Object o Six months is added to birthday Date Object o 10 years is added to birthday Date Object The output for PHASE-I and PHASE-II will be:
Read Full Discussion Thread for this article