Advertisement
sergAccount

Untitled

Feb 6th, 2021
584
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.82 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package javaapplication21;
  7.  
  8. import java.awt.Color;
  9.  
  10. public class Line {
  11.    
  12.     int x1; // (x1,y1) - первая точка
  13.     int y1;
  14.     int x2; // (x2,y2) - вторая точка
  15.     int y2;
  16.     Color color;
  17.    
  18.     // Alt+Insert
  19.     public Line(int x1, int y1, int x2, int y2, Color color) {
  20.         this.x1 = x1;
  21.         this.y1 = y1;
  22.         this.x2 = x2;
  23.         this.y2 = y2;
  24.         this.color = color;
  25.     }
  26.  
  27.     //
  28.     public int getX1() {
  29.         return x1;
  30.     }
  31.  
  32.     public void setX1(int x1) {
  33.         this.x1 = x1;
  34.     }
  35.  
  36.     public int getY1() {
  37.         return y1;
  38.     }
  39.  
  40.     public void setY1(int y1) {
  41.         this.y1 = y1;
  42.     }
  43.  
  44.     public int getX2() {
  45.         return x2;
  46.     }
  47.  
  48.     public void setX2(int x2) {
  49.         this.x2 = x2;
  50.     }
  51.  
  52.     public int getY2() {
  53.         return y2;
  54.     }
  55.  
  56.     public void setY2(int y2) {
  57.         this.y2 = y2;
  58.     }
  59.  
  60.     public Color getColor() {
  61.         return color;
  62.     }
  63.  
  64.     public void setColor(Color color) {
  65.         this.color = color;
  66.     }
  67. }
  68.  
  69. /*
  70.  
  71. 1) Создать класс Line, который описывает отрезок на плоскости
  72. Класс должен содержать четыре свойства - для указания первой и
  73. второй точек данного отрезка.
  74. Все свойства должны быть значениями типа int.
  75. Определить get и set методы в классе Line для получения значений свойств.
  76. Определить конструктор класса Line с параметрами.
  77. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement