Guest User

Untitled

a guest
Feb 20th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.83 KB | None | 0 0
  1. package geo;
  2.  
  3. public class Linie {
  4.  
  5.     private double x1, x2, y1, y2, linethickness;
  6.     private String linecolor;
  7.  
  8.     // Konstruktor1 mit Start- und Endkoordinaten
  9.     public Linie(double x1, double x2, double y1, double y2) {
  10.         this.x1 = x1;
  11.         this.x2 = x2;
  12.         this.y1 = y1;
  13.         this.y2 = y2;
  14.     }
  15.  
  16.     // Konstruktor2 mit Linienstärke
  17.     public Linie(double x1, double x2, double y1, double y2, double linethicknes) {
  18.         this(x1, x2, y1, y2);
  19.         this.linethickness = linethicknes;
  20.     }
  21.  
  22.     // Konstruktor3 mit Linienfarbe
  23.     public Linie(double x1, double x2, double y1, double y2,
  24.             double linethickness, String linecolor) {
  25.         this(x1, x2, y1, y2, linethickness);
  26.         // this.linecolor = setLinecolor(linecolor);
  27.         this.linecolor = linecolor;
  28.     }
  29.  
  30.     // Konstruktor4 default Konstruktor
  31.     public Linie String() {
  32.         return null;
  33.  
  34.     }
  35.  
  36.     public double getX1() {
  37.         return x1;
  38.     }
  39.  
  40.     public void setX1(double x1) {
  41.         this.x1 = x1;
  42.     }
  43.  
  44.     public double getX2() {
  45.         return x2;
  46.     }
  47.  
  48.     public void setX2(double x2) {
  49.         this.x2 = x2;
  50.     }
  51.  
  52.     public double getY1() {
  53.         return y1;
  54.     }
  55.  
  56.     public void setY1(double y1) {
  57.         this.y1 = y1;
  58.     }
  59.  
  60.     public double getY2() {
  61.         return y2;
  62.     }
  63.  
  64.     public void setY2(double y2) {
  65.         this.y2 = y2;
  66.     }
  67.  
  68.     public double getLinethickness() {
  69.         return linethickness;
  70.     }
  71.  
  72.     public void setLinethickness(double linethickness) {
  73.         this.linethickness = (linethickness);
  74.     }
  75.  
  76.     public String getLinecolor() {
  77.         return linecolor;
  78.     }
  79.  
  80.     public String setLinecolor(String linecolor) {
  81.         if (linecolor != "schwarz" && linecolor != "blau"
  82.                 && linecolor != "grün" && linecolor != "gelb")
  83.             throw new RuntimeException("Farbe nicht zulässig");
  84.         return linecolor;
  85.     }
  86.  
  87.     @Override
  88.     public String toString() {
  89.         return ("Diese Linie hat folgende Attribute: \n" + x1 + x2 + y1 + y2
  90.                 + linethickness + linecolor);
  91.     }
  92.  
  93.  
  94. }
Add Comment
Please, Sign In to add comment