Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class NuPeople {
- private String name;
- private boolean livingAtCampus;
- /**
- * Cunstructs a new Nu person.
- *
- * @param n the name to set
- * @param liv the livingAtCampus to set
- */
- public NuPeople(String n, boolean liv){
- name=n;
- livingAtCampus=liv;
- }
- /**
- * Gets the name of a NU person.
- *
- * @return the name
- */
- public String getName(){
- return name;
- }
- /**
- * Shows is the person living at campus.
- *
- * @return livingAtCampus
- */
- public boolean isLivingAtCampus(){
- return livingAtCampus;
- }
- /**
- * Sets the status if the person living at Campus.
- *
- * @param liv to livingAtCanpus to set
- */
- public void setLivingAtCampus(boolean liv){
- livingAtCampus=liv;
- }
- /**
- * Shows the cost of Dormitory Fee
- */
- public void calculaeDormFee(){
- System.out.println("Dorm fee depends on the status of the person.");
- }
- /**
- * Person goes to a lecture
- */
- public void goToLecture(){
- System.out.println(name+" is on lecture.");
- }
- /**
- *
- * @return
- */
- public String toString(){
- if (livingAtCampus){
- return name+" lives at Campus.";
- }
- return name+" lives in the city.";
- }
- }
- public class Student extends NuPeople{
- private int yearOfStudy;
- /**
- *
- * @param na
- * @param live
- * @param y the yearOfStudy to set
- */
- public Student(String na, boolean live, int y){
- super(na, live);
- yearOfStudy=y;
- }
- /**
- * Shows the cost of Dormitory Fee
- */
- public void calculaeDormFee(){
- if (isLivingAtCampus()){
- System.out.println("Dormitory fee for students is 20,000tg.");
- } else{
- System.out.println("the student does not live at campus.");
- }
- }
- /**
- *
- * @return
- */
- public int yearsLeft(){
- return 4-yearOfStudy;
- }
- /**
- *
- * @return
- */
- public String toString(){
- if (isLivingAtCampus()){
- return "Student " + getName()+" lives at Campus.";
- }
- return "student "+getName()+" lives in the city.";
- }
- }
- public class Professor extends NuPeople{
- private String office;
- public Professor(String n, boolean liv, String of){
- super(n, liv);
- office=of;
- }
- /**
- * Shows the cost of Dormitory Fee
- */
- public void calculaeDormFee(){
- if (isLivingAtCampus()){
- System.out.println("Dormitory fee for professors is 70,000tg.");
- } else{
- System.out.println("The professor does not live at campus.");
- }
- }
- public void goToOffice(){
- System.out.println("Proffessor " + getName()+ " is in office "+office +".");
- }
- /**
- *
- * @return
- */
- public String toString(){
- if (isLivingAtCampus()){
- return "Professor " + getName()+" lives at Campus.";
- }
- return "Professor "+getName()+" lives in the city.";
- }
- }
- public class TA extends NuPeople{
- private String degree;
- public TA(String n, boolean liv, String deg){
- super(n, liv);
- degree=deg;
- }
- /**
- *
- * @return the degree
- */
- public String getDegree(){
- return degree;
- }
- /**
- *
- * @return
- */
- public String toString(){
- if (isLivingAtCampus()){
- return "TA " + getName()+" lives at Campus.";
- }
- return "TA "+getName()+" lives in the city.";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment