public Shape createShape(string code) { Shape shape; switch (code) { case "K": shape = new Krug(0, 0); return(shape); case "T": shape = new triangle(0, 0); return(shape); case "S": shape = new square(0, 0); return(shape); case "G": shape = new Group(0); return(shape); default: return(null); } //return null; }
public void add(string s, int dx, int dy) // public void add(Shape value) { if (s == "Круг") { var t = new Krug(dx, dy); var node = new Node(t); if (Head == null) { Head = node; } else { Tail.next = node; } Tail = node; current = Tail; } else if (s == "Треугольник") { var t = new triangle(dx, dy); var node = new Node(t); if (Head == null) { Head = node; } else { Tail.next = node; } Tail = node; current = Tail; } else { var t = new square(dx, dy); var node = new Node(t); if (Head == null) { Head = node; } else { Tail.next = node; } Tail = node; current = Tail; } count++; }
public void addNew(string s, int dx, int dy, int w, int h) // public void add(Shape value) { if (s == "Круг") { var t = new Krug(dx, dy); if (t.check(w, h)) { var node = new Node(t); if (Head == null) { Head = node; } else { Tail.next = node; } Tail = node; current = Tail; count += 1; } } else if (s == "Треугольник") { var t = new triangle(dx, dy); if (t.check(w, h)) { var node = new Node(t); if (Head == null) { Head = node; } else { Tail.next = node; } Tail = node; current = Tail; count += 1; } } else { var t = new square(dx, dy); if (t.check(w, h)) { var node = new Node(t); if (Head == null) { Head = node; } else { Tail.next = node; } Tail = node; current = Tail; count += 1; } } }