Postingan

Menampilkan postingan dari November, 2018

Foxes and Rabbit

Gambar
Class yang digunakan : 1. Rabbit import java.util.List; import java.util.Random; public class Rabbit { // Characteristics shared by all rabbits (static fields). // The age at which a rabbit can start to breed. private static final int BREEDING_AGE = 5; // The age to which a rabbit can live. private static final int MAX_AGE = 40; // The likelihood of a rabbit breeding. private static final double BREEDING_PROBABILITY = 0.15; // The maximum number of births. private static final int MAX_LITTER_SIZE = 4; // A shared random number generator to control breeding. private static final Random rand = Randomizer.getRandom(); // Individual characteristics (instance fields). // The rabbit's age. private int age; // Whether the rabbit is alive or not. private boolean alive; // The rabbit's position. private Location location; // The field occupied. ...

Database Akademik (Inheritance)

Source Code 1. Mahasiswa /** * Write a description of class Mahasiswa here. * * @author (Lutfiyanti) * @version (a version number or a date) */ public class Mahasiswa extends Database { private String jurusan; private String alamat; private String agama; public Mahasiswa (String n, String i, String j, String a1, String a2) { super (n,i); jurusan = j; alamat = a1; agama = a2; } public String toString() { return "Mahasiswa[super=" + super.toString() + ",jurusan=" + jurusan + ",alamat=" + alamat + ",agama=" + agama + "]"; } } 2. Matkul /** * Write a description of class Matkul here. * * @author (Lutfiyanti) * @version (a version number or a date) */ public class Matkul extends Database { private String semester; public Matkul (String n, String i, String s) ...