Create a class for four-dimensional points called FourDPoint that is a subclass of Point from the java.awt package. - Java Object Oriented Design

Java examples for Object Oriented Design:Inheritance

Description

Create a class for four-dimensional points called FourDPoint that is a subclass of Point from the java.awt package.

Demo Code

import java.awt.Point;
public class Main{

    public static void main(String[] arguments) {
        FourDPoint np = new FourDPoint(5, 5, 4, 100);
        System.out.println("x is " + np.x);
        System.out.println("y is " + np.y);
        System.out.println("z is " + np.z);
        System.out.println("t is " + np.t);
    }/*  w w  w .  j  a  v  a 2s.  c o m*/

}
class FourDPoint extends Point {
    int z;
    int t;

    FourDPoint(int x, int y, int inZ, int inT) {
        super(x,y);
        this.z = inZ;
        this.t = inT;
    }
}

Related Tutorials