Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- /**
- *
- * @author Tibi
- */
- public class Dolgozo {
- private String nev;
- private int kor;
- private boolean nem;
- private String vegzettseg;
- private int fizetes;
- public Dolgozo(String nev, int kor, boolean nem, String vegzettseg, int fizetes)
- throws InvalidDataException {
- if( fizetes < 60000 ) {
- throw new InvalidDataException();
- }
- if( ( ( vegzettseg.compareTo( "Egyetem" ) == 0 ) ||
- ( vegzettseg.compareTo( "Bsc" ) == 0 ) ||
- ( vegzettseg.compareTo( "Msc" ) == 0 ) ) && (fizetes < 120000 ) ) {
- throw new InvalidDataException();
- }
- if( ( nem && ( kor > 60 ) ) || ( !nem && ( kor > 56 ) ) ) {
- throw new InvalidDataException();
- }
- this.nev = nev;
- this.kor = kor;
- this.nem = nem;
- this.vegzettseg = vegzettseg;
- this.fizetes = fizetes;
- }
- public int getFizetes() {
- return fizetes;
- }
- public void setFizetes(int fizetes) throws InvalidDataException {
- if( fizetes < 60000 ) {
- throw new InvalidDataException();
- }
- if( ( ( vegzettseg.compareTo( "Egyetem" ) == 0 ) ||
- ( vegzettseg.compareTo( "Bsc" ) == 0 ) ||
- ( vegzettseg.compareTo( "Msc" ) == 0 ) ) && (fizetes < 120000 ) ) {
- throw new InvalidDataException();
- }
- this.fizetes = fizetes;
- }
- public int getKor() {
- return kor;
- }
- public void setKor(int kor) throws InvalidDataException {
- if( ( nem && ( kor > 60 ) ) || ( !nem && ( kor > 56 ) ) ) {
- throw new InvalidDataException();
- }
- this.kor = kor;
- }
- public boolean isNem() {
- return nem;
- }
- public void setNem(boolean nem) {
- this.nem = nem;
- }
- public String getNev() {
- return nev;
- }
- public void setNev(String nev) {
- this.nev = nev;
- }
- public String getVegzettseg() {
- return vegzettseg;
- }
- public void setVegzettseg(String vegzettseg) {
- this.vegzettseg = vegzettseg;
- }
- public static void main( String[] args ) {
- try {
- Dolgozo A = new Dolgozo("Kiss Ilona",59,false,"Egyetem",200000);
- }
- catch( InvalidDataException e ) {
- System.out.println( e.toString() );
- }
- }
- }
- class InvalidDataException extends Exception {
- InvalidDataException(){}
- @Override
- public String toString() {
- return "Ervenytelen adat!";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment