Java Programming
Design a class named Person and its two subclasses named Student
and Employee. A person has a name, address, phone number, and email
address. A student has a class status (freshman, sophomore, junior,
or senior). Define the status as a constant. An employee has an
office, salary, date hired. Define a class named MyDate that
contains the fields year, month, and day.
Override the toString method in each class to display the class
name and the person's name.
Draw the UML diagram for classes and implement them. Write a test
program that creates a Person, Student and Employee and invokes
their toString() methods.
Note: Please do the simple solution so that it is easy to understand.
import java.util.*;
class Person
{
private String name;
private String address;
private String phoneNumber;
private String email;
public Person(String name,String address,String
phoneNumber,String email)//constructor
{
this.name = name;
this.address =
address;
this.phoneNumber =
phoneNumber;
this.email =
email;
}
//get Methods
public String getName()
{
return name;
}
public String getAddress()
{
return address;
}
public String getPhoneNumber()
{
return
phoneNumber;
}
public String getEmail()
{
return email;
}
}
class Student extends Person
{
private static String status;
public Student(String name,String address,String
phoneNumber,String email,String status)
{
super(name,address,phoneNumber,email);
this.status =
status;
}
public String toString()
{
return "\nName :
"+getName()+ " Address : "+getAddress() +" Phone Number :
"+getPhoneNumber()+" Email : "+ getEmail()+" Status
:"+status;
}
}
class MyDate
{
private int year;
private int month;
private int day;
public MyDate(int day,int month,int year)
{
this.day = day;
this.month =
month;
this.year = year;
}
public String toString()
{
return "
"+day+"/"+month+"/"+year;
}
}
class Employee extends Person
{
private String office;
private double salary;
private MyDate dateHired;//MyDate object
public Employee(String name,String
address,String phoneNumber,String email,String office,double
salary,MyDate dateHired)
{
super(name,address,phoneNumber,email);
this.office =
office;
this.salary =
salary;
this.dateHired =
dateHired;
}
public String toString()
{
return "\nName :
"+getName()+ " Address : "+getAddress() +" Phone Number :
"+getPhoneNumber()+" Email : "+ getEmail()+" Office : "+office +"
Salary : "+salary + " Hiredate : "+dateHired;
}
}
class Test
{
public static void main (String[] args)
{
Student s = new Student("Jim
Lee","445-
DownStreet,London","446-676686","[email protected]","sophomore");
System.out.println(s.toString());
MyDate d = new
MyDate(5,12,2016);
Employee e = new Employee("kathy
Williams","7676-Hillside,NJ","3636-575775","[email protected]","6756,street
-2,NJ",7666.67,d);
System.out.println(e.toString());
}
}
Output:
Name : Jim Lee Address : 445- DownStreet,London Phone Number : 446-676686 Email : [email protected] Status :sophomore
Name : kathy Williams Address : 7676-Hillside,NJ Phone Number : 3636-575775 Email : [email protected] Office : 6756,street -2,NJ Salary :
7666.67 Hiredate : 5/12/2016
Java Programming Design a class named Person and its two subclasses named Student and Employee. A...
a c++ program (The Person, Student, Employee, Faculty, and Staff classes) Design a class named Person and its two subclasses named Student and Employee. Make Faculty and Staff subclasses of Employee. A person has a name, address, phone number, and email address. A student has a class status (freshman, sophomore, junior, or senior). Define the status as a constant. An employee has an office, salary, and date hired. Use the MyDate classto create an object for date hired. A faculty...
In Java(The Person, Student, Employee, Faculty, and Staff classes)Design a class named Person and its two derived classes named Student and Employee. MakeFaculty and Staff derived classes of Employee. A person has a name, address, phone number, and e-mail address. A student has a class status (freshman, sophomore, junior, or senior). An employee has an office, salary, and date hired. Define a class namedMyDate that contains the fields year, month, and day. A faculty member has office hours and a rank....
Implement an abstract class named Person and two subclasses named Student and Staff in Java. A person has a name, address, phone number and e-mail address. A student has a credit hour status (freshman, sophomore, junior, or senior). Define the possible status values using an enum. Staff has an office, salaray, and date-hired. Implement the above classes in Java. Provide Constructors for classes to initialize private variables. Getters and setters should only be provided if needed. Override the toString() method...
Part I: (The Myate class) Design a class named MyDate. The class contains: • The data fields year, month, and day that represent a date. Month is 0-based, i.e., 0 is for January. • A no-arg constructor that creates a MyDate object for the current date. • A constructor that constructs a MyDate object with a specified elapsed time since midnight, January 1, 1970, in milliseconds. • A constructor hat constructs a MyDate object with the specified year, month, and...
Concepts Tested in this Program: Class Design Constructors Objects Inheritance Program: Design a class named Person and its two subclasses, Student and Employee. Make Faculty and Staff subclasses of Employee. A Person object has a name, address, phone number, and email address (all Strings). A Student Object has a class status (freshman, sophomore, junior, or senior). Define the status as a final String variable. An Employee Object has an office number, salary (both ints ), and a date hired. Use...
Please answer all the questions 2. Design two programs named BaseClass and SubClass. In BaseClass, define a variable xVar (type: char, value: 65), and a method myPrint to print xVar. SubClass is a subclass of BaseClass. In SubClass, define a variable yVar (type: int, value: 16) and another variable strVar (type: String, value: "java program!"). There is also a method myPrint to print the value of yVar and strVar in SubClass, as well as an additional method printAll, in which...
Please provide the code for the last part(client side program). yes i have all the class implementations. ``` person.h #ifndef PERSON_H #define PERSON_H #include <string> using namespace std; class person { public: person(); string getname() const; string getadd() const; string getemail() const; string getphno() const; string toString() const; private: string name; string add; string email; string phno; }; ```person.cpp #include "person.h" person::person() { name = "XYZ"; add="IIT "; email="%%%%"; phno="!!!!!"; } string person::getname() const { return name; } string person::getadd()...
1. Design and implement classes. Design a class named Account and its two subclasses named Checking and Saving. Make Flexible and NotFlexbile subclasses of Saving. An account has a name, address, phone number, and balance. A checking account has a overdraft limit. A saving account has an interest rate. A flexible saving account has the accumulated interest rate. A none flexible account has the expected accumulated interest rate at the maturity of the account. Override the toString method in each...
In this laboratory, we are going to build a base class and a collection of derived classes. Write the code to implement the class Person. A person has a name, address,telephone number and and E-Mail address. Be sure to include accessor functions to return each of these values. Create a derived class Student which has a class status (freshman, sophomore, junior, or senior). Create a derived class Employee which has the attributes office, salary, and date hired. Now define a...
This is for Java Programming Please use comments Customer and Employee data (15 pts) Problem Description: Write a program that uses inheritance features of object-oriented programming, including method overriding and polymorphism. Console Welcome to the Person Tester application Create customer or employee? (c/e): c Enter first name: Frank Enter last name: Jones Enter email address: frank44@ hot mail. com Customer number: M10293 You entered: Name: Frank Jones Email: frank44@hot mail . com Customer number: M10293 Continue? (y/n): y Create customer...