public class Kaktus { Random randomKaktus = new Random(); int wyborKaktus; int przedzialKaktus; Image imgKaktus; Image imge1; Image imge2; Image imge3; public Kaktus(){ przedzialKaktus = randomKaktus.nextInt(1150)+1170; BufferedImage kaktus1 = null; BufferedImage kaktus2 = null; BufferedImage kaktus3 = null; try { kaktus1 = ImageIO.read(new File(getClass().getResource("/grafika/kaktus11.bmp").toURI())); kaktus2 = ImageIO.read(new File(getClass().getResource("/grafika/kaktus22.bmp").toURI())); kaktus3 = ImageIO.read(new File(getClass().getResource("/grafika/kaktus33.bmp").toURI())); } catch (IOException e) { e.printStackTrace(); } catch (URISyntaxException e) { e.printStackTrace(); } imge1 = kaktus1; imge2 = kaktus2; imge3 = kaktus3; } public void losowanieKaktusa(){ wyborKaktus = randomKaktus.nextInt(2); if(wyborKaktus==0){ imgKaktus=imge1; } if(wyborKaktus==1){ imgKaktus=imge2; } if(wyborKaktus==2){ imgKaktus=imge3; } } }