DESAIN INTERFACE DAN KONTROL OBJEK


 Buatlah program dengan menggunakan objek control statemen ifelse untuk perintah logika pada status dan Jabatan dari karyawan. Setiap status dan jabatan mempengaruhi gaji sesorang karyawan.pada aplikasi program dibawah menggunakan konsep pewarisan (Inheritance).  
Source code:
Public Class Form1

    Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim objPegawai As New pegawai
        Dim objPegawaiTetap As New PegawaiTetap
        Dim objPegawaiHonorer As New PegawaiHonorer

        With objPegawai
            .NIP = TextBox1.Text
            .Nama = TextBox2.Text
            .Alamat = TextBox3.Text
            .Status = ComboBox1.Text
            .Jabatan = ComboBox2.Text

            If ComboBox2.Text = "Direktur" Then
                TextBox4.Text = 7000000
            ElseIf ComboBox2.Text = "Manager" Then
                TextBox4.Text = 3500000
            ElseIf ComboBox2.Text = "Staff" Then
                TextBox4.Text = 1500000
            Else
                TextBox4.Text = 1000000
            End If

            .Status = ComboBox1.Text
            If ComboBox1.Text = "Tetap" Then
                With objPegawaiTetap
                    .Gapok = TextBox4.Text
                    TextBox5.Text = 2 * TextBox4.Text
                    .TunjanganTetap = TextBox5.Text
                    TextBox6.Text = 0
                    TextBox7.Text = .HitungGajiTetap(.Gapok, .mTunjanganTetap)
                End With
            ElseIf ComboBox1.Text = "Honorer" Then
                With objPegawaiHonorer
                    .Gapok = TextBox4.Text
                    TextBox5.Text = 0
                    TextBox6.Text = 25 * 15000
                    .TunjanganTransport = TextBox6.Text
                    TextBox7.Text = .HitungGajiHonorer(.mGapok, .mTunjanganTransport)
                End With
            End If
        End With
    End Sub
End Class

Public Class pegawai
    Public mNIP As String
    Public mNama As String
    Public mAlamat As String
    Public mStatus As String
    Public mJabatan As String
    Public mGapok As Integer

    Public Property NIP() As String
        Get
            Return mNIP
        End Get

        Set(ByVal value As String)
            mNIP = value
        End Set
    End Property
    Public Property Nama() As String
        Get
            Return mNama
        End Get
        Set(ByVal value As String)
            mNama = value
        End Set
    End Property
    Public Property Alamat() As String
        Get
            Return mAlamat
        End Get
        Set(ByVal value As String)
            mAlamat = value
        End Set
    End Property
    Public Property Status() As String
        Get
            Return mStatus
        End Get
        Set(ByVal value As String)
            mStatus = value
        End Set
    End Property
    Public Property Jabatan() As String
        Get
            Return mJabatan
        End Get
        Set(ByVal value As String)
            mJabatan = value
        End Set
    End Property
    Public Property Gapok() As String
        Get
            Return mGapok
        End Get
        Set(ByVal value As String)
            mGapok = value
        End Set
    End Property

    Public Function HitungGaji(ByVal mGapok As Integer) As Long
        Return mGapok
    End Function
End Class

Public Class PegawaiTetap
    Inherits pegawai
    Public mTunjanganTetap As Integer

    Public Property TunjanganTetap() As Integer
        Get
            Return mTunjanganTetap
        End Get
        Set(ByVal value As Integer)
            mTunjanganTetap = value
        End Set
    End Property

    Public Function HitungGajiTetap(ByVal mGapok As Integer, ByVal mTunjanganTetap As Integer) As Long
        Return mGapok + mTunjanganTetap
    End Function
End Class

Public Class PegawaiHonorer
    Inherits pegawai
    Public mTunjanganTransport As Integer

    Public Property TunjanganTransport() As Integer
        Get
            Return mTunjanganTransport
        End Get
        Set(ByVal value As Integer)
            mTunjanganTransport = value
        End Set
    End Property

    Public Function HitungGajiHonorer(ByVal mGapok As Integer, ByVal mTunjanganTransport As Integer) As Long
        Return mGapok + mTunjanganTransport
    End Function
End Class


Tampilan

Soal- Soal
Buatlah Aplikasi penjualan Tiket Teater 21 atau Bioskop, dimana aplikasi tersebut akan menampilkan pesat pada saat penonton berumur < 17 tahun. Berikan fungsi pada TextboxTgl lahir sehingga secara otomatis dapat membaca apabila operator memasukan tahun dan sistem akan menkalkulasikan tahun tersebut dengan tahun yang ada disistem aplikasi(sekarang).
1.             Buatlah penjualan Tiket Teater 21 atau Bioskop, dimana aplikasi tersebut akan menampilkan pesan pada saat penonton berumur < 17 tahun. Berikan fungsi pada TextBoxTglLahir sehingga secara otomatis dapat membaca apabila operator memasukan tahun dan system akan menkalkulasikan tehun tersebut dengan tahun yang ada di system aplikasi (sekarang).
a.       Source code
Class Teater 21
Public Class Teater21
    Private mNama As String
    Private mTTL As Date
    Private mJumKursi As String
    Private mKelas As String
    Private mPembayaran As String
    Public Property Nama() As String
        Get       
            Return mNama
        End Get

        Set(ByVal value As String)
            mNama = value
        End Set
    End Property
    Public Property TTL() As Date
        Get
            Return mTTL
        End Get
        Set(ByVal value As Date)
            mTTL = value
        End Set
    End Property
    Public Property JumKursi() As String
        Get
            Return mJumKursi
        End Get
        Set(ByVal value As String)
            mJumKursi = value
        End Set
    End Property

    Public Property Kelas() As String
        Get
            Return mKelas
        End Get
        Set(ByVal value As String)
            mKelas = value
        End Set
    End Property
    Public Property Pembayaran() As String
        Get
            Return mPembayaran
        End Get
        Set(ByVal value As String)
            mPembayaran = value
        End Set
    End Property
    Public Function HrgKursi(ByVal mKelas As String) As Long
        If mKelas = "Reguler" Then
            Return 50000
        Else
            Return 100000
        End If
    End Function
    Public Function TotBayar(ByVal mJumkursi As Integer, ByVal HrgKursi As Long) As Long
        Return mJumkursi * HrgKursi
    End Function
    Public Function Umur(ByVal TTL As Date)
        Return Now.Year - TTL.Year
    End Function
End Class
Class Form1
Public Class Form1
    Private Sub cmbKelas_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbKelas.TextChanged
        Dim objTeater21 As New Teater21
        With objTeater21
            .Kelas = cmbKelas.Text
            .JumKursi = txtJumKursi.Text
            txtTotBayar.Text = .TotBayar(.JumKursi, .HrgKursi(.Kelas))
            txtHrgKursi.Text = .HrgKursi(.Kelas)
        End With
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        txtKembalian.Text = txtPembayaran.Text - txtTotBayar.Text
        Dim objTeater21 As New Teater21
        With objTeater21
            .TTL = DateTimePicker1.Text
            If .Umur(.TTL) < 17 Then
                MessageBox.Show("Maaf Umur Anda " & .Umur(.TTL) & " Tahun, jadi tidak layak untuk menonton", " Konfirmasi")
                txtNama.Clear()
            Else
                MessageBox.Show("Umur Anda " & .Umur(.TTL) & " Tahun, layak untuk menonton", "Konfirmasi")
            End If
        End With
    End Sub
End Class








b.      Sreenshoot Program
 




    












0 Response to "DESAIN INTERFACE DAN KONTROL OBJEK"

Post a Comment