Date problem..

I got an error with my code..

Page 1 of 1

0 Replies - 597 Views - Last Post: 07 August 2009 - 08:21 AM Rate Topic: -----

#1 NeedHelpPlease  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 02-August 09

Date problem..

Post icon  Posted 07 August 2009 - 08:21 AM

Hi! I need help. Primarily, I had a problem with my Date.. I am really confused and don't know how to do the department thing. And where to put it.

Your help will be highly appreciated.

Thank you..


public class Employee
{
	private String name;
	private Date birthDate;
	private String profile;

	public String getDetails()
	{
		//
	}  
}


In this class, include a constructor that takes in 2 arguments to initialize the name and the date of birth of an employee. The employee’s profile is initialized by invoking the getDetails() method.
* Overload the constructor so that it takes only one argument, the name of the employee, to initialize the Employee’s object called the constructor in number 1.
* Implement the getDetails() method that returns the name and date of birth of an employee.
* A secretary is an employee. Using the Employee class definition in the code, define the class. Secretary that has an instance variable called department. Include in this class, a constructor to initialize an object of type Secretary.


---------------------------------------------------------------------------------------------------------------------

Below are the codes I made for the problem..

import java.io.*;
public class Employee {
   private String name;
   private Date birthDate;
   private String profile;

   // constructor to initialize name, birth date and hire date
   public Employee( String name, Date birthDate )
   {
	  name = name;
	  birthDate = birthDate;

   }

   // convert Employee to String format
   public String toEmployeeString()
   {
	  return name +  
		 "  Birthday: " + birthDate.toDateString();
   }

} // end class Employee


Is This A Good Question/Topic? 0
  • +

Page 1 of 1