Skip to content

Instantly share code, notes, and snippets.

@kruttaras
Created June 2, 2016 21:14
Show Gist options
  • Select an option

  • Save kruttaras/c1291790d9ab1f7f9bd9c802c72d5b49 to your computer and use it in GitHub Desktop.

Select an option

Save kruttaras/c1291790d9ab1f7f9bd9c802c72d5b49 to your computer and use it in GitHub Desktop.
Сингтони для 11 завдання
public class Line
{
private int x1;
private int x2;
private int y1;
private int y2;
private static Line instance;
private Line() {}
public static Line getInstance(int x1,int y1, int x2, int y2)
{
if (instance == null)
{
instance = new Line();
instance.x1 = x1;
instance.x2 = x2;
instance.y1 = y1;
instance.y2 = y2;
}
return instance;
}
}
////////////// POINT ////////////////////////////////////////////
public class Point
{
private int x;
private int y;
private static Point instance;
private Point() {}
public static Point getInstance(int x,int y)
{
if (instance == null)
{
instance = new Point();
instance.x = x;
instance.y = y;
}
return instance;
}
}
////////////Rectangle//////////////////
public class Rectangle
{
private int x1;
private int x2;
private int x3;
private int y1;
private int y2;
private int y3;
private static Rectangle instance;
private Rectangle() {}
public static Rectangle getInstance(int x1,int y1, int x2, int y2,int x3, int y3)
{
if (instance == null)
{
instance = new Rectangle();
instance.x1 = x1;
instance.x2 = x2;
instance.x3 = x3;
instance.y1 = y1;
instance.y2 = y2;
instance.y3 = y3;
}
return instance;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment