Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /***************************************/
- /** 20151008 Inheritance **/
- /** Maker : Yan **/
- /** E-Mail : [email protected] **/
- /** Date : 2015/10/08 am.11:30 **/
- /***************************************/
- public class Main {
- public static void main(String[] args) {
- vector v1 = new vector();
- v1.InValue1(10, 20);
- System.out.printf("X1 = %3d, Y1 = %3d\n",
- v1.GetX1(), v1.GetY1());
- vectors v2 = new vectors();
- v2.InValue1(100, 200);
- v2.InValue2(300, 400);
- System.out.printf("X1 = %2d, Y1 = %2d\nX2 = %3d, Y2 = %3d\n",
- v2.GetX1(), v2.GetY1(),
- v2.GetX2(), v2.GetY2());
- }
- }
- class vector {
- protected
- int x1;
- int y1;
- public
- void InValue1(int inX, int inY) { x1 = inX; y1 = inY; }
- int GetX1() { return x1; }
- int GetY1() { return y1; }
- }
- class vectors extends vector {
- private
- int x2;
- int y2;
- public
- void InValue2(int inX, int inY) { x2 = inX; y2 = inY; }
- int GetX2() { return x2; }
- int GetY2() { return y2; }
- }
Advertisement
Add Comment
Please, Sign In to add comment