Java Interface Exercises 6

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.