Defines a pointclass used to represent points in three-dimensional space (with three coordinates). Requirements are as follows:
(1) You can generate a point object with a specific coordinate.
(2) provides a way to set three coordinates.
(3) provides a way to calculate the square of the distance from the origin of the point.
(4) write the main class program validation.
Public classPoint {Private intA,b,c; Point (intAintBintc) { This. a=A; This. b=b; This. c=C; } Public intGeta () {returnA; } Public voidSetA (inta) { This. A =A; } Public intGetb () {returnb; } Public voidSETB (intb) { This. B =b; } Public intGetC () {returnC; } Public voidSETC (intc) { This. C =C; } Public voidJuli () {System.out.println ("Coordinates" +a+ "," +b+ "," +c+ "the distance from the origin of the square =" + (a*a+b*b+c*c)); } Public Static voidMain (string[] args) {point P=NewPoint (2,2,2); P.juli (); P.seta (3); P.SETB (5); P.SETC (9); P.juli (); }
Java Interface Exercises 6