fatalaa

Dolgozo

Apr 11th, 2012
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.70 KB | None | 0 0
  1. /*
  2.  * To change this template, choose Tools | Templates
  3.  * and open the template in the editor.
  4.  */
  5.  
  6. /**
  7.  *
  8.  * @author Tibi
  9.  */
  10. public class Dolgozo {
  11.     private String nev;
  12.     private int kor;
  13.     private boolean nem;
  14.     private String vegzettseg;
  15.     private int fizetes;
  16.  
  17.     public Dolgozo(String nev, int kor, boolean nem, String vegzettseg, int fizetes)
  18.             throws InvalidDataException {
  19.         if( fizetes < 60000 ) {
  20.             throw new InvalidDataException();
  21.         }
  22.         if( ( ( vegzettseg.compareTo( "Egyetem" ) == 0 ) ||
  23.             (   vegzettseg.compareTo( "Bsc" ) == 0 )     ||
  24.             ( vegzettseg.compareTo( "Msc" ) == 0 ) ) &&  (fizetes < 120000 ) ) {
  25.             throw new InvalidDataException();
  26.         }
  27.         if( ( nem && ( kor > 60 ) ) || ( !nem && ( kor > 56 ) ) ) {
  28.             throw new InvalidDataException();
  29.         }
  30.         this.nev = nev;
  31.         this.kor = kor;
  32.         this.nem = nem;
  33.         this.vegzettseg = vegzettseg;
  34.         this.fizetes = fizetes;
  35.     }
  36.  
  37.     public int getFizetes() {
  38.         return fizetes;
  39.     }
  40.  
  41.     public void setFizetes(int fizetes) throws InvalidDataException {
  42.         if( fizetes < 60000 ) {
  43.             throw new InvalidDataException();
  44.         }
  45.         if( ( ( vegzettseg.compareTo( "Egyetem" ) == 0 ) ||
  46.             (   vegzettseg.compareTo( "Bsc" ) == 0 )     ||
  47.             ( vegzettseg.compareTo( "Msc" ) == 0 ) ) &&  (fizetes < 120000 ) ) {
  48.             throw new InvalidDataException();
  49.         }
  50.         this.fizetes = fizetes;
  51.     }
  52.  
  53.     public int getKor() {
  54.         return kor;
  55.     }
  56.  
  57.     public void setKor(int kor) throws InvalidDataException {
  58.         if( ( nem && ( kor > 60 ) ) || ( !nem && ( kor > 56 ) ) ) {
  59.             throw new InvalidDataException();
  60.         }
  61.         this.kor = kor;
  62.     }
  63.  
  64.     public boolean isNem() {
  65.         return nem;
  66.     }
  67.  
  68.     public void setNem(boolean nem) {
  69.         this.nem = nem;
  70.     }
  71.  
  72.     public String getNev() {
  73.         return nev;
  74.     }
  75.  
  76.     public void setNev(String nev) {
  77.         this.nev = nev;
  78.     }
  79.  
  80.     public String getVegzettseg() {
  81.         return vegzettseg;
  82.     }
  83.  
  84.     public void setVegzettseg(String vegzettseg) {
  85.         this.vegzettseg = vegzettseg;
  86.     }
  87.    
  88.     public static void main( String[] args ) {
  89.         try {
  90.             Dolgozo A = new Dolgozo("Kiss Ilona",59,false,"Egyetem",200000);
  91.         }
  92.         catch( InvalidDataException e ) {
  93.             System.out.println( e.toString() );
  94.         }
  95.        
  96.     }
  97. }
  98.  
  99. class InvalidDataException extends Exception {
  100.     InvalidDataException(){}
  101.    
  102.     @Override
  103.     public String toString() {
  104.         return "Ervenytelen adat!";
  105.     }
  106. }
Advertisement
Add Comment
Please, Sign In to add comment