Advertisement
Yuvalxp8

Family Class (Constructors etc.)

Sep 6th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.26 KB | None | 0 0
  1. public class Family
  2. {
  3.     String name; //surname
  4.     int num; //number of family members
  5.     int numStudent; //members in highSchool
  6.     double taxesDiscount = 0;
  7.    
  8.     public Family(String name, int numStudent, int num)
  9.     {
  10.         this.name = name;
  11.         this.numStudent = numStudent;
  12.         this.num = num;
  13.     }
  14.  
  15.     public String getName()
  16.     {
  17.         return name;
  18.     }
  19.  
  20.     public void setName(String name)
  21.     {
  22.         this.name = name;
  23.     }
  24.  
  25.     public int getNum()
  26.     {
  27.         return num;
  28.     }
  29.  
  30.     public void setNum(int num)
  31.     {
  32.         this.num = num;
  33.     }
  34.  
  35.     public int getNumStudent()
  36.     {
  37.         return numStudent;
  38.     }
  39.  
  40.     public void setNumStudent(int numStudent)
  41.     {
  42.         this.numStudent = numStudent;
  43.     }
  44.  
  45.     public double getTaxesDiscount()
  46.     {
  47.         return taxesDiscount;
  48.     }
  49.  
  50.     public void setTaxesDiscount(double taxes)
  51.     {
  52.         this.taxesDiscount = taxes;
  53.     }
  54.    
  55.     public void reduction()
  56.     {
  57.         if(num > 6)
  58.         {
  59.             taxesDiscount = taxesDiscount + 100;
  60.         }
  61.         for(int i = 0 ; i > numStudent ; i ++)
  62.         {
  63.             taxesDiscount = taxesDiscount + 40;
  64.         }
  65.     }
  66.    
  67.     public void addStudents()
  68.     {
  69.         numStudent ++;
  70.     }
  71.    
  72.     public void addNum()
  73.     {
  74.         num ++;
  75.     }
  76.    
  77.     public String toString()
  78.     {
  79.         return "Family [name=" + name + ", num=" + num + ", numStudent=" + numStudent + ", taxesDiscount="+ taxesDiscount + "]";
  80.     }
  81.    
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement