package dokumenty; public class Element { private String typ; private int[] pudelko; public Element(String typ, int[] pudelko) { this.typ = typ; this.pudelko = pudelko; } public String pobierzTyp() { return this.typ; } public int[] pobierzPudelko() { return this.pudelko; } public static Element ParsujLinie(String linia) { String[] napisy = linia.split(" "); if (napisy.length != 5) { return null; } String typ = napisy[0]; int xTop = Integer.parseInt(napisy[1]); int yTop = Integer.parseInt(napisy[2]); int xBot = Integer.parseInt(napisy[3]); int yBot = Integer.parseInt(napisy[4]); Element element = new Element(typ, new int[]{xTop, yTop, xBot, yBot}); return element; } public String toString() { return typ + " [" + pudelko[0] + "," + pudelko[1] + "," + pudelko[2] + "," + pudelko[3] + "]"; } }