-1

please teach me how to convert the code into a interface. What should be done is that there is a person class which has a name, address, gender, and phone. then a student, faculty, staff class which inherits the person class. but the student has a course and major, faculty has a rank and research area, and staff has a position and an office

this is my person code //Person.java

class Person{
private String myName;
private String myAddress;
private char myGender;
private int myPhone;

public Person()
{
myName = "";
myAddress = "";
myGender = 'N';
myPhone = 0;
}

public Person(String name, String address, char gender, int phone){
myName = name;
myAddress = address;
myGender = gender;
myPhone = phone;
} 

public String getName(){
return myName;
} 

public String getAddress()
{ 
return myAddress; 
} 

public char getGender() 
{ 
return myGender; 
} 

public int getPhone()
{
return myPhone;
}

public void setName(String name) 
{ 
myName = name; 
} 

public void setAddress(String address) 
{ 
myAddress = address; 
} 

public void setGender(char gender) 
{ 
myGender = gender; 
} 

public void setPhone(int phone)
{
myPhone = phone;
}

public String toString() 
{ 
return myName + ", address: " + myAddress + ", gender: " + myGender + ", phone: " + myPhone; 
} 
}

this is my student code //Student.java

class Student extends Person 
{ 
private String myCourse;
private String myMajor;

public Student() 
{ 
super(); 

myCourse = ""; 
myMajor = ""; 
} 

public Student(String name, String address, char gender, int phone, 
             String course, String major)
{ 
super(name, address, gender, phone);

myCourse = course; 
myMajor = major; 
} 

public String getCourse() 
{ 
return myCourse; 
} 

public String getMajor() 
{ 
return myMajor; 
} 

public void setCourse(String course) 
{ 
myCourse = course; 
} 

public void setMajor(String major) 
{ 
myMajor = major; 
} 

public String toString() 
{ 
return super.toString() + ", course: " + myCourse + ", major: " + myMajor; 
} 
}

this is my faculty code //Faculty.java

public class Faculty extends Person
{ 
private String myRank; 
private String myResearch;

public Faculty() 
{ 
super(); 

myRank = ""; 
myResearch = ""; 
}  

public Faculty(String name, String address, char gender, int phone, String rank, String research)
{
super(name, address, gender, phone); 

myRank = rank;
myResearch = research;
} 

public String getRank()
{
    return myRank;
}

public String getResearch()
{
return myResearch;
} 

public void setRank(String rank)
{
myRank = rank;
} 

public void setResearch(String research)
{
myResearch = research;
} 

public String toString() { 
    return super.toString() + ", rank: " + myRank + ", research: " + myResearch; 
} 
}

this is my staff code //Staff.java

public class Staff extends Person
{ 
private String myPosition; 
private String myOffice;

public Staff() 
{ 
super(); 

myPosition = ""; 
myOffice = ""; 
}  

public Staff(String name, String address, char gender, int phone, String position, String office)
{
super(name, address, gender, phone); 

myPosition = position;
myOffice = office;
} 

public String getPosition()
{
return myPosition;
}

public String getOffice()
{
return myOffice;
} 

public void setPosition(String position)
{
myPosition = position;
} 

public void setResearch(String office)
{
myOffice = office;
} 

public String toString() { 
return super.toString() + ", position: " + myPosition + ", office: " + myOffice; 
} 
}

enter image description here

please teach me how to convert the code into a interface

Ole V.V.
  • 81,772
  • 15
  • 137
  • 161
  • 3
    This is *far* too broad for a Stack Overflow question, essentially what you're looking for is any tutorials on any given Java GUI framework/technology. Fortunately, a quick Google search finds another very old Stack Overflow question which, while currently off-topic, has been preserved for posterity and may be a good place for you to start: https://stackoverflow.com/questions/7358775/java-gui-frameworks-what-to-choose-swing-swt-awt-swingx-jgoodies-javafx – David Jan 28 '19 at 18:59

1 Answers1

3

Basicly these are just the Models that your application is going to use. You cannot create a user interface having just these Models, but you can make it yourself.

In Java, you have various libraries which help you to create GUI, for example JavaFX or Swing (not really recommended today).

When it comes to the project architecture, what you can use is a design pattern called Model-View-Controller (MVC).

There are also other questions which consider basics of user interfaces in Java, which could help you: How to create a GUI in Java or Create an application GUI by Javafx

And if you are still unsure of which GUI library you should use, see this question: Java GUI frameworks. What to choose? Swing, SWT, AWT, SwingX, JGoodies, JavaFX, Apache Pivot?

linoskoczek
  • 135
  • 5