gitweb on Svarog
projekti pod git sistemom za održavanje verzija -- projects under
the git version control system
2 public final static int IZLAZ
= -99;
3 public final static int ZID
= -11;
4 public final static int ERROR
= Integer
.MIN_VALUE
;
6 private int visina
, sirina
;
8 private boolean[][] pos
;
10 public int getSirina() {
14 public int getVisina() {
18 public void setPos(int x
, int y
, boolean b
) {
19 if (0 <= x
&& x
< sirina
&& 0 <= y
&& y
< visina
) {
24 public boolean getPos(int x
, int y
) {
25 if (0 <= x
&& x
< sirina
&& 0 <= y
&& y
< visina
) {
32 public int getMat(int x
, int y
) {
33 if (0 <= x
&& x
< sirina
&& 0 <= y
&& y
< visina
) {
40 public Mapa(int sirina
, int visina
) {
43 mat
= new int[sirina
][visina
];
44 pos
= new boolean[sirina
][visina
];
47 public Mapa(String imeFajla
) {
48 if (!Svetovid
.testIn(imeFajla
)) {
49 throw new RuntimeException("Fajl za kreiranje mape ("
50 + imeFajla
+ ") nije prisupacan");
53 sirina
= Svetovid
.in(imeFajla
).readInt();
54 visina
= Svetovid
.in(imeFajla
).readInt();
55 mat
= new int[sirina
][visina
];
56 pos
= new boolean[sirina
][visina
];
57 for (int j
= 0; j
< visina
; j
++) {
58 for (int i
= 0; i
< sirina
; i
++) {
59 mat
[i
][j
] = Svetovid
.in(imeFajla
).readInt();
62 Svetovid
.closeIn(imeFajla
);
65 public static Mapa
ucitajIzFajla(String imeFajla
) {
66 if (!Svetovid
.testIn(imeFajla
)) {
70 return new Mapa(imeFajla
);
74 public void stampaj() {
75 if (visina
!= 0 && sirina
!= 0) {
76 System
.out
.println(visina
+ " " + sirina
);
77 for (int j
= 0; j
< visina
; j
++) {
78 for (int i
= 0; i
< sirina
; i
++) {
79 System
.out
.print(mat
[i
][j
] + "\t");
86 public String
toString() {
87 return "Mapa velicine " + sirina
+ " x " + visina
;
Svarog.pmf.uns.ac.rs/gitweb
maintanance
Doni Pracner