30 lines
853 B
Java
30 lines
853 B
Java
class PendaftaranKelas {
|
|
static int kuotaTerisi = 0;
|
|
final static int MAX_KUOTA = 25;
|
|
String namaMhs;
|
|
|
|
PendaftaranKelas(String nama) {
|
|
this.namaMhs = nama;
|
|
}
|
|
|
|
void prosesDaftar() {
|
|
if (kuotaTerisi < MAX_KUOTA) {
|
|
kuotaTerisi++;
|
|
System.out.printf("%s -> BERHASIL MASUK KELAS A (Terisi: %d)\n", this.namaMhs, kuotaTerisi);
|
|
} else {
|
|
System.out.printf("%s -> GAGAL! KELAS PENUH, TERLEMPAR KE KELAS B\n", this.namaMhs);
|
|
}
|
|
}
|
|
}
|
|
|
|
public class daftarkelas {
|
|
public static void main(String[] args) {
|
|
System.out.println("LIRS KELAS PBO DIMULAI!\n");
|
|
|
|
for (int i = 1; i <= 26; i++) {
|
|
PendaftaranKelas mhsBaru =
|
|
new PendaftaranKelas(String.format("Mahasiswa %02d", i));
|
|
mhsBaru.prosesDaftar();
|
|
}
|
|
}
|
|
} |