i have a problem in this , i tried to write a code for college class but i can't got it
Question:-
Design an Abstract class named Person and its two subclasses. A class named
Student and an Abstract class named Employee. Make Administrator 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. Define a class named MyDate that contains the fields
year, month, and day. A faculty member has office hours and a rank. A staff
member has a title. Override the toString method in each class to display the
class name and the person's name.
Design a class called College having a name and group of Students,
Administrators and Staff members. A College will accept Students until a
negative phone number is entered, while the Administrators and the Staff
members are input by the user. However, any College can't accept more
than 1000 Students, 135 Administrators and 200 Staff members.
My Code
public abstract class Person
{
String name;
String Address;
int PhoneNum;
String Email ;
public String toString()
{
return "Person name";
}
}
======================================
public class Student extends Person
{
String freshman;
String sophomore;
String junior;
public String toString()
{
return "Student extends Person";
}
}
===========================================
public class Employee extends Person
{ int OfficeNum ;
int salary ;
int DateHired;
public void SetOfficeNum(int x)
{
this.OfficeNum=x;
}
public int GetOfficeNum()
{
return OfficeNum;
}
public void SetSalary(int x)
{
this.salary=x;
}
public int Getsalary()
{
return salary;
}
public void SetDateHired(int x)
{
this.DateHired=x;
}
public int GetDateHired()
{
return DateHired;
}
public String toString()
{
return "Employee extends Person";
}
}
================================================
public class Administrator extends Employee
{
int OfficeHours;
String Rank;
public void SetOfficeHours(int x)
{
this.OfficeHours=x;
}
public int GetOfficeHours()
{
return OfficeHours;
}
public void SetRank(String x)
{
this.Rank=x;
}
public String GetRank()
{
return Rank;
}
public String toString()
{
return "Administrator extends Employee";
}
}
==================================================
public class Staff extends Employee
{
String title;
public void SetTitle(String x)
{
this.title=x;
}
public String GetTitle()
{
return title;
}
public String toString()
{
return " Staff extends Employee";
}
}
=========================================================
import javax.swing.JOptionPane;
public class College
{
String name;
Student []A1=new Student[1000];
Administrator []A2=new Administrator[135];
Staff []A3=new Staff[200];
public void Students()
{ String z=JOptionPane.showInputDialog("please enter student num: ");
int x=Integer.parseInt(z);
while (x<=A1.length)
{
String a=JOptionPane.showInputDialog("please enter student name: ");
this.name=a;
}
}
}

New Topic/Question
Reply



MultiQuote






|