package points;

import java.awt.Color;
import java.awt.Graphics;

// solution pour l'exercice 3
public class SimpleNamedPoint implements DrawableNamedPoint {
  // partie reprise de l'exercice 1
  private String name;
  private int px;
  private int py;
  public SimpleNamedPoint(String s, int x, int y) {
    name = s;
    px = x;
    py = y;
  }
  public String toString() {
    return name + " (" + px + ',' + py + ')';
  }
  // la suite est pour l'exercice 2
  public String getName() {
    return name;
  }
  public int getX() {
    return px;
  }
  public int getY() {
    return py;
  }
  // pour l'exercice 3
  public void paint(Graphics g) {
    int x = getX();
    int y = getY();
    int radius = 2;
    g.setColor(Color.black);
    g.fillOval(x - radius, y - radius, 2 * radius, 2 * radius);
    g.drawString(name, x + 2 * radius, y);
  }
}

