Selasa, 24 Januari 2012

Karyawan

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Soal2;

/**
 *
 * @author Eduardus Hardika Sandy A. (1053140084)
 */
public class Karyawan {

    private String nama;
    private int tglLahir;
    private int blnLahir;
    private int thnLahir;

    public Karyawan() {
    }

    /**
     * @param nama the nama to set
     */
    public void setNama(String nama) {
        this.nama = nama;
    }

    /**
     * @param tglLahir the tglLahir to set
     */
    public void setTglLahir(int tanggal) throws Exception {
        if (tanggal > 0 && tanggal <= 31) {
            this.tglLahir = tanggal;
        } else {
            throw new Exception("Salah Tanggal");
        }
    }

    /**
     * @param blnLahir the blnLahir to set
     */
    public void setBlnLahir(int bulan) throws Exception {
        if (bulan > 0 && bulan <= 12) {
            this.blnLahir = bulan;
        } else {
            throw new Exception("Salah Bulan");
        }
    }

    /**
     * @param thnLahir the thnLahir to set
     */
    public void setThnLahir(int tahun) throws Exception {
        if (tahun > 0 && tahun >= 1900) {
            this.thnLahir = tahun;
        } else {
            throw new Exception("Salah Tahun");
        }
    }
}

Tidak ada komentar:

Posting Komentar