/** Overriding and hiding example @author A. Ozgelen */ public class Quarter extends Coin { public static String classDescription() { return "Quarter class"; } @Override public String toString() { return "Quarter"; } public static void main(String[] args) { Quarter quater = new Quarter(); Coin coin = quater; System.out.println(Coin.classDescription()); System.out.println(Quarter.classDescription()); System.out.println(coin); } } class Coin { public Coin(){ this(25); } public Coin(int value) { this.value = value ; flip(); } public void flip() { face = (int) (Math.random() * 2); } public int getFace() { return face; } public int getValue() { return value; } public static String classDescription() { return "Coin class"; } @Override public String toString() { return "Value:" + getValue(); } // static constants public static final int HEADS = 0 ; public static final int TAILS = 1 ; // data fields private int face ; // head or tail private int value ; // in cents }