Interface and abstract class aggregation in UML

I was given a task in which I must implement an applet that mimics the solar system, which has a sun with orbits of the planets, and the planets should have moons orbiting the planets. I have successfully implemented the animation, but in order to get full credit, we need to use the following UML: The UML given by the teacher

I understand that the framework has an instance Sun, but Sunimplements methods in the interface Orbitand has an instance OrbitingBodycreated using the constructor Planet, etc. I am not undesrtand - this is the relationship in UML between an interface Orbitand an abstract class OrbitingBody.

/****************************************************************/
import java.awt.*;

@SuppressWarnings("serial")
public class Sun implements Orbit {
    private Dimension dim;
    private OrbitingBody earth;
    private OrbitingBody mars;
    //Other vars

    public void init(Dimension dim) {
        // CODE irrelevant for the question
    }

    public void setPlanetPosition() {
        // CODE irrelevant for the question
    }

    public int calX(int distance, int angle){
        // CODE irrelevant for the question
    }
    public int calY(int distance, int angle){
       // CODE irrelevant for the question
    }

    public void draw(Graphics g) {
        // CODE irrelevant for the question
    }
}


/****************************************************************/
import java.awt.*;

@SuppressWarnings("serial")
public class Planet extends OrbitingBody implements Orbit {
    private Moon moon;
    private Moon eris;


    Planet(int x, int y, Color color) {
        super.x = x;
        super.y = y;
        moon = new Moon();
        eris = new Moon();
        this.color = color;
    }

    public int calX(int distance, int angle){
        // CODE irrelevant for the question
    }
    public int calY(int distance, int angle){
        // CODE irrelevant for the question
    }
}



/****************************************************************/
  public interface Orbit {
    int calX(int distance, int angle);
    int calY(int distance, int angle);
}



/****************************************************************/
   import java.awt.*;

public abstract class OrbitingBody {
    protected Color color;
    protected int x, y;
    protected int radius = 25;

    void setPosition(int x, int y) {
        this.x = x;
        this.y = y;
    }

    public void draw(Graphics g) {
        // CODE irrelevant for the question
    }
}
+4
source share
1 answer

I understand your confusion.

UML- ( ).

UML

  • ( ) . . . Planet Sun Moon Planet?

  • UML «Orbit» {Orbiting Body} . , Orbit ? , "interface" . Orbiting Body, UML . , abstract? , Orbiting Body

  • " " "" . , Orbit Orbiting Body. , Orbiting Body Orbit

  • " and 'Orbit Sun Planet Planet Moon. , , Orbit Orbiting Body, - , . ( ).
    , , Sun Planet Planet Moon. .

UML - . codemonkey, UML . ( ) / .

:

  • , (Planet, Moon) (Sun, Planet).
    • ?
    • .
  • Moon Planet?. Planet 2 Moon s? - Moon s
  • Sun Planet.
+1
source

Source: https://habr.com/ru/post/1695556/


All Articles