Advertisement
UniQuet0p1

Untitled

Feb 23rd, 2022
889
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.10 KB | None | 0 0
  1. package oo.hide;
  2.  
  3. public class PointSet {
  4.  
  5.     private Point[] points ;
  6.  
  7.  
  8.  
  9.     public PointSet(int capacity) {
  10.         points = new Point[capacity];
  11.     }
  12.     public PointSet() {
  13.         this(10);
  14.     }
  15.  
  16.     public void add(Point point) {//если есть места в массиве, можно добавить Point
  17.         if (points.length >= 10) return;
  18.  
  19.         points[points.length] = point;
  20.     }
  21.  
  22.  
  23.     public int size() {
  24.         return points.length;
  25.     }
  26.  
  27.     public String toString() {
  28.         String hell = "";
  29.         for (int i = 0; i < points.length; i++) {
  30.             if (i == 0) {
  31.                 hell += points[i].toString();
  32.             } else {
  33.                 hell += (", " + points[i].toString());
  34.             }
  35.         }
  36.         return hell;
  37.     }
  38.  
  39.     public boolean contains(Point point) {
  40.         for (Point value : points) {
  41.             if (value == point) return true;
  42.         }
  43.         return  false;
  44.     }
  45.  
  46.     public PointSet subtract(PointSet other) {
  47.  
  48.     }
  49.  
  50.     public PointSet intersect(PointSet other) {
  51.         return null;
  52.     }
  53. }
  54.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement