/* * Lecture7.java 1.0 04/03/22 * * Example for OOP * */ package dk.itu.oop.lecture7; class Lecture7{ public static void main(String args[]) { System.out.println("Starting Lecture7..."); PointAndLineUser plu = new PointAndLineUser(); plu.MoveAll(); } } class Point { private int x; private int y; public Point(int x, int y){ this.x = x; this.y = y; } public void move(int dx, int dy){ x+=dx; y+=dy; } } class Line extends Point { private int x; private int y; public Line(int x1,int y1, int x2, int y2){ super(x1,x2); this.x = x2; this.y = y2; } public void move(int dx, int dy){ super.move(dx,dy); x += dx; y += dy; } } class PointAndLineUser { Point p; Line l; PointAndLineUser(){ p = new Point(3,4); l = new Line( 10, 20, 30, 40 ); } void MoveAll(){ p.move(7,1); l.move(3,6); } }