idastan97

CSCI152 L4 P1

Jan 26th, 2017
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.80 KB | None | 0 0
  1. public class NuPeople {
  2.     private String name;
  3.     private boolean livingAtCampus;
  4.    
  5.     /**
  6.      * Cunstructs a new Nu person.
  7.      *
  8.      * @param n the name to set
  9.      * @param liv the livingAtCampus to set
  10.      */
  11.     public NuPeople(String n, boolean liv){
  12.         name=n;
  13.         livingAtCampus=liv;
  14.     }
  15.    
  16.     /**
  17.      * Gets the name of a NU person.
  18.      *
  19.      * @return the name
  20.      */
  21.     public String getName(){
  22.         return name;
  23.     }
  24.    
  25.     /**
  26.      * Shows is the person living at campus.
  27.      *
  28.      * @return livingAtCampus
  29.      */
  30.     public boolean isLivingAtCampus(){
  31.         return livingAtCampus;
  32.     }
  33.    
  34.     /**
  35.      * Sets the status if the person living at Campus.
  36.      *
  37.      * @param liv to livingAtCanpus to set
  38.      */
  39.     public void setLivingAtCampus(boolean liv){
  40.         livingAtCampus=liv;
  41.     }
  42.    
  43.     /**
  44.      * Shows the cost of Dormitory Fee
  45.      */
  46.     public void calculaeDormFee(){
  47.         System.out.println("Dorm fee depends on the status of the person.");
  48.     }
  49.    
  50.     /**
  51.      * Person goes to a lecture
  52.      */
  53.     public void goToLecture(){
  54.         System.out.println(name+" is on lecture.");
  55.     }
  56.    
  57.     /**
  58.      *
  59.      * @return
  60.      */
  61.     public String toString(){
  62.         if (livingAtCampus){
  63.             return name+" lives at Campus.";
  64.         }
  65.         return name+" lives in the city.";
  66.     }
  67. }
  68.  
  69. public class Student extends NuPeople{
  70.     private int yearOfStudy;
  71.    
  72.     /**
  73.      *
  74.      * @param na
  75.      * @param live
  76.      * @param y the yearOfStudy to set
  77.      */
  78.     public Student(String na, boolean live, int y){
  79.         super(na, live);
  80.         yearOfStudy=y;
  81.     }
  82.    
  83.     /**
  84.      * Shows the cost of Dormitory Fee
  85.      */
  86.     public void calculaeDormFee(){
  87.         if (isLivingAtCampus()){
  88.             System.out.println("Dormitory fee for students is 20,000tg.");
  89.         } else{
  90.             System.out.println("the student does not live at campus.");
  91.         }
  92.     }
  93.    
  94.     /**
  95.      *
  96.      * @return
  97.      */
  98.     public int yearsLeft(){
  99.         return 4-yearOfStudy;
  100.     }
  101.    
  102.     /**
  103.      *
  104.      * @return
  105.      */
  106.     public String toString(){
  107.         if (isLivingAtCampus()){
  108.             return "Student " + getName()+" lives at Campus.";
  109.         }
  110.         return "student "+getName()+" lives in the city.";
  111.     }
  112. }
  113.  
  114.  
  115. public class Professor extends NuPeople{
  116.     private String office;
  117.    
  118.     public Professor(String n, boolean liv, String of){
  119.         super(n, liv);
  120.         office=of;
  121.     }
  122.    
  123.     /**
  124.      * Shows the cost of Dormitory Fee
  125.      */
  126.     public void calculaeDormFee(){
  127.         if (isLivingAtCampus()){
  128.             System.out.println("Dormitory fee for professors is 70,000tg.");
  129.         } else{
  130.             System.out.println("The professor does not live at campus.");
  131.         }
  132.     }
  133.    
  134.    
  135.     public void goToOffice(){
  136.         System.out.println("Proffessor " + getName()+ " is in office "+office +".");
  137.     }
  138.    
  139.     /**
  140.      *
  141.      * @return
  142.      */
  143.     public String toString(){
  144.         if (isLivingAtCampus()){
  145.             return "Professor " + getName()+" lives at Campus.";
  146.         }
  147.         return "Professor "+getName()+" lives in the city.";
  148.     }
  149. }
  150.  
  151. public class TA extends NuPeople{
  152.     private String degree;
  153.    
  154.     public TA(String n, boolean liv, String deg){
  155.         super(n, liv);
  156.         degree=deg;
  157.     }
  158.    
  159.     /**
  160.      *
  161.      * @return the degree
  162.      */
  163.     public String getDegree(){
  164.         return degree;
  165.     }
  166.    
  167.     /**
  168.      *
  169.      * @return
  170.      */
  171.     public String toString(){
  172.         if (isLivingAtCampus()){
  173.             return "TA " + getName()+" lives at Campus.";
  174.         }
  175.         return "TA "+getName()+" lives in the city.";
  176.     }
  177. }
Advertisement
Add Comment
Please, Sign In to add comment