Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'dart:io';
- bool repeat = true;
- void main() {
- Atm atm_satu = Atm(123, 5000);
- Atm atm_dua = Atm(456, 10000);
- do {
- stdout.write("\nMasukkan PIN : ");
- var pinMasuk = int.parse(stdin.readLineSync());
- if(pinMasuk == atm_satu.pin) {
- atm_satu.menu();
- } else if(pinMasuk == atm_dua.pin) {
- atm_dua.menu();
- } else {
- print("Pin Salah");
- }
- }while(repeat == true);
- }
- class Atm {
- int pin;
- int saldo;
- Atm(int pin, int saldo) {
- this.pin = pin;
- this.saldo = saldo;
- }
- void menu() {
- do {
- print("Selamat datang \n1. Tarik Tunai\n2. Setor Tunai\n3. Cek Saldo\n4. Ganti Akun\n5. Keluar Aplikasi\n\n");
- stdout.write('Pilih Menu : ');
- var option = int.parse(stdin.readLineSync());
- switch(option) {
- case 1:
- stdout.write('\nTarik Tunai \nNominal : ');
- int withdrawal = int.parse(stdin.readLineSync());
- if(withdrawal > saldo) {
- print("\nSaldo anda tidak cukup");
- print("Saldo anda sekarang $saldo");
- } else {
- saldo -= withdrawal;
- print("\nJumlah Penarikan : $withdrawal\nSaldo anda sekarang : $saldo\n\n");
- }
- break;
- case 2:
- stdout.write('\nSetor Tunai \nNominal :');
- int deposited = int.parse(stdin.readLineSync());
- saldo += deposited;
- print("\nJumlah Setoran : $deposited\nSaldo anda sekarang : $saldo\n\n");
- break;
- case 3:
- print("\nSaldo anda sekarang $saldo\n\n");
- break;
- case 4:
- main();
- break;
- case 5:
- print("\nTerima Kasih");
- exit(0);
- break;
- default:
- print('\nMenu yang ada pilih tidak ada\n\n');
- }
- } while(repeat == true);
- }
- }
Add Comment
Please, Sign In to add comment