|
PLz any help in this question i need code of "How to create a data structure that represent a Customer??" that structure will hold variables First Name, Last Name, Salary, Employee ID , Email id , Gender.
PLZZZ help
<Added>
I mean ""How to create a data structure that represent a EMployee??" Not Customer
|
|
|
public class EmployeeTest
{
public static void main(String[] args)
{
Employee john = new Employee("John", "Brown", 211, Employee.MALE,
100.0, "jb@elbow.net");
Employee peggy = new Employee("Peggy Sue", "Fuller", 99);
System.out.println("john = " + john + "\n" +
"peggy = " + peggy);
peggy.setSalary(1000.00);
System.out.println("peggy = " + peggy);
}
}
class Employee
{
String firstName;
String lastName;
int employeeID;
int gender;
double salary;
String emailID;
final static int FEMALE = 0;
final static int MALE = 1;
public Employee(String first, String last, int id, int sex,
double salary, String email)
{
firstName = first;
lastName = last;
employeeID = id;
gender = sex;
this.salary = salary;
emailID = email;
}
public Employee(String first, String last, int id)
{
this(first, last, id, 0, 0.0, "");
}
public void setSalary(double d) { salary = d; }
public String toString()
{
return "name:" + firstName + " " + lastName + ", id:" + employeeID +
", gender:" + (gender == FEMALE ? "female" : "male") +
", salary:" + salary + ", emailID:" + emailID;
}
}
|
|
|
|
|
|
|
|
|
// |