aircor Posted January 12, 2008 Report Share Posted January 12, 2008 Czesc sluchajcie mam problem z tym labiryntem chodzi o to ze mi sie nie wyswietla Czy moglby mi ktos pomoc i to poprawic ? Jezyk: JAVA public static void main(String[] args) { // TODO Auto-generated method stub int ret = 0; int x = 0; int y = 4; int a =0; int[][] lab={ {0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0} }; do{ if (a!=2 && lab[x+1][y]>0){ ret=lab[x+1][y]; x=x+1; a=1; continue; } if ( a!=1 && lab[x-1][y]>0){ ret=lab[x-1][y]; x=x-1; a=2; continue; } if (a!=4 && lab[x][y+1]>0){ ret=lab[x][y+1]; y=y+1; a=3; continue; } if (a!=3 && lab[x][y-1]>0){ ret=lab[x][y-1]; y=y-1; a=4; continue; } }while(lab[x][y]<2); System.out.println("Wyjście"); } } Link to comment Share on other sites More sharing options...
sazian Posted January 12, 2008 Report Share Posted January 12, 2008 1) mógłbyś chociaż napisać jaki to język 2) stosuj kolorowanie składni (tu pewnie będzie java lub c) 3) jak ma się wyświetlić skoro nie ma żadnego polecenia które miało by to zrobić ?? jedyne co służy do wyświetlania czegokolwiek w tym kodzie to System.out.println("Wyjście"); Link to comment Share on other sites More sharing options...
aircor Posted January 12, 2008 Author Report Share Posted January 12, 2008 To jest java co do tego wyswietlenia to nie wiem a jak ma zostac to zmienione Link to comment Share on other sites More sharing options...
Toster Posted January 12, 2008 Report Share Posted January 12, 2008 Uzywalem tylko J2me nie wiem czy to w se dziala ale powinna byc metoda public void onPaint(Graphics g); wtedy masz wskaznik na obiekt po ktorym mozesz mazac. Prawdopodobnie powinienes odziedziczyc po jakiejs klasie jak Forma , okno czy cos w ten desen Always Dark<br /> Link to comment Share on other sites More sharing options...
aircor Posted January 12, 2008 Author Report Share Posted January 12, 2008 cholera siedzialem juz nad tym pare godzin i nic nie mam pojecia jak to zrobic dlatego zawitalem tutaj Link to comment Share on other sites More sharing options...
Toster Posted January 12, 2008 Report Share Posted January 12, 2008 Poszukaj przykladu z uzyciem klas Canvas albo Graphics. Zobaczysz jak tam rysuja i juz Always Dark<br /> Link to comment Share on other sites More sharing options...
aircor Posted January 12, 2008 Author Report Share Posted January 12, 2008 szukalem i mi nie dziala dlatego wzucilem caly kod moze ktos bedzie w stanie na to zaradzic i cos podmieni Link to comment Share on other sites More sharing options...
Toster Posted January 12, 2008 Report Share Posted January 12, 2008 import java.awt.*; public class circle extends java.applet.Applet { private int mouseX, mouseY; private boolean mouseclicked = false; public void init() { setBackground(Color.magenta); } public boolean mouseDown(Event e, int x, int y ) { mouseX=x; mouseY=y; mouseclicked = true; repaint(); return true; } public void paint( Graphics g ) { g.setColor(Color.blue); if (mouseclicked) { g.fillOval(mouseX, mouseY, 10, 10); mouseclicked = false; } } } Pierwszy przyklad z sieci, wyglada ze dziala. Wiecej w linku: http://www.cs.clemson.edu/~cs428/resources.../JTGraphEx.html Always Dark<br /> Link to comment Share on other sites More sharing options...
aircor Posted January 12, 2008 Author Report Share Posted January 12, 2008 ten nie moze byc nie moze go tak rysowac potrzebyje aby sam mi go wyswietlil krok po kroku jak przechodzi w eclipsie na tym polu {0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0} }; I nic wiecej ma sie nie pokazywac Zamiast jedynek bedzie zmieniac sie na kwadrat i tak do konca az znajdzie wyjscie Link to comment Share on other sites More sharing options...
Toster Posted January 12, 2008 Report Share Posted January 12, 2008 no i w czym problem ? W paincie robisz 2 petle jedna po x druga po y. Wstawiasz do nich warunek, jesli lab[x][y] = 1 to rysujesz kwadrat w odpowiednich wspolrzednych. Nie bardzo rozumiem co ci nie wychodzi ? Always Dark<br /> Link to comment Share on other sites More sharing options...
aircor Posted January 12, 2008 Author Report Share Posted January 12, 2008 Jak to wzoce do eclipsy to pokazuje mi tylko na dole w tym okienku co ma wyswietlac przejscie calego labiryntu sam napis "wyjscie" tak jak by szukał w pamieci Link to comment Share on other sites More sharing options...
sazian Posted January 12, 2008 Report Share Posted January 12, 2008 że co ?? Link to comment Share on other sites More sharing options...
Toster Posted January 12, 2008 Report Share Posted January 12, 2008 mowisz o moim programie czy swoim ? Bo nie mam pojecia o co ci chodzi Always Dark<br /> Link to comment Share on other sites More sharing options...
aircor Posted January 12, 2008 Author Report Share Posted January 12, 2008 Jak to wzoce do eclipsy to pokazuje mi tylko na dole w tym okienku co ma wyswietlac przejscie calego labiryntu sam napis "wyjscie" tak jak by szukał w pamieci to jest odnosnie mojego kodu Link to comment Share on other sites More sharing options...
Toster Posted January 12, 2008 Report Share Posted January 12, 2008 no przeciez masz tam tylko jedna metode System.out ktora wyswietla ten tekst wiec nie bardzo rozumiem czego sie spodziewales ? Wkleilem ci kod do narysowania czegos i powiedzialem jak nalezy przeprowadzic rysowanie z twojej tablicy. Always Dark<br /> Link to comment Share on other sites More sharing options...
Force Posted January 13, 2008 Report Share Posted January 13, 2008 No bo jak ma cokolwiek wyświetlać, skoro nie stworzyłeś ani formularza ani apltu tylko program konsolowy, to może tylko tekst w konsoli wyświetlać i tyle Baza tysięcy lotnisk: http://airportsbase.com Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.