Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package geo;
- public class Linie {
- private double x1, x2, y1, y2, linethickness;
- private String linecolor;
- // Konstruktor1 mit Start- und Endkoordinaten
- public Linie(double x1, double x2, double y1, double y2) {
- this.x1 = x1;
- this.x2 = x2;
- this.y1 = y1;
- this.y2 = y2;
- }
- // Konstruktor2 mit Linienstärke
- public Linie(double x1, double x2, double y1, double y2, double linethicknes) {
- this(x1, x2, y1, y2);
- this.linethickness = linethicknes;
- }
- // Konstruktor3 mit Linienfarbe
- public Linie(double x1, double x2, double y1, double y2,
- double linethickness, String linecolor) {
- this(x1, x2, y1, y2, linethickness);
- // this.linecolor = setLinecolor(linecolor);
- this.linecolor = linecolor;
- }
- // Konstruktor4 default Konstruktor
- public Linie String() {
- return null;
- }
- public double getX1() {
- return x1;
- }
- public void setX1(double x1) {
- this.x1 = x1;
- }
- public double getX2() {
- return x2;
- }
- public void setX2(double x2) {
- this.x2 = x2;
- }
- public double getY1() {
- return y1;
- }
- public void setY1(double y1) {
- this.y1 = y1;
- }
- public double getY2() {
- return y2;
- }
- public void setY2(double y2) {
- this.y2 = y2;
- }
- public double getLinethickness() {
- return linethickness;
- }
- public void setLinethickness(double linethickness) {
- this.linethickness = (linethickness);
- }
- public String getLinecolor() {
- return linecolor;
- }
- public String setLinecolor(String linecolor) {
- if (linecolor != "schwarz" && linecolor != "blau"
- && linecolor != "grün" && linecolor != "gelb")
- throw new RuntimeException("Farbe nicht zulässig");
- return linecolor;
- }
- @Override
- public String toString() {
- return ("Diese Linie hat folgende Attribute: \n" + x1 + x2 + y1 + y2
- + linethickness + linecolor);
- }
- }
Add Comment
Please, Sign In to add comment