Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package uts;
- import java.util.Scanner;
- public class payment {
- private int id;
- public int tipe;
- private int jumlah;
- private float harga;
- payment (int tipe){
- this.tipe = tipe;
- Scanner scan = new Scanner(System.in);
- if (tipe == 1 ) {
- System.out.println("Masukkan nomer > ");
- setId(scan.nextInt());
- scan.nextLine();
- } else {
- System.out.println("Masukkan kode > ");
- setId(scan.nextInt());
- scan.nextLine();
- }
- System.out.println("Masukkan Nominal > ");
- setJumlah(scan.nextInt());
- scan.nextLine();
- float harga = tipe == 1 ? 1000 : 2500;
- hitung(harga);
- }
- public int getJumlah(){
- return this.jumlah;
- }
- public void setJumlah(int jumlah){
- this.jumlah = jumlah;
- }
- public int getId(){
- return this.id;
- }
- public void setId(int id){
- this.id = id;
- }
- public float getHarga(){
- return this.harga;
- }
- public void setHarga(float harga){
- this.harga = harga;
- }
- public void hitung(float harga) {
- setHarga(harga + this.jumlah);
- }
- public void getInfo() {
- if (this.tipe == 1 ) {
- System.out.println("<<<------------------------------------>>>");
- System.out.println("Nomor Telepon\t\t: " + this.id);
- System.out.println("Nominal\t\t: " + this.jumlah);
- System.out.println("Harga\t\t\t: " + this.harga);
- System.out.println("<<<------------------------------------>>>");
- } else {
- System.out.println("<<<------------------------------------>>>");
- System.out.println("Nomor Telepon\t\t: " + this.id);
- System.out.println("Nominal\t\t: " + this.jumlah);
- System.out.println("Harga\t\t\t: " + this.harga);
- System.out.println("<<<------------------------------------>>>");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement