Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.RandomAccessFile;
- int przeliczZamowienie(String nazwa_pliku, String nazwa_towaru){
- int ilosc_sztuk = 0;
- try{
- RandomAccessFile raf = new RandomAccessFile(nazwa_pliku, "rw");
- raf.seek(0);
- while(raf.getFilePointer()<raf.length()){
- String nazwa = raf.readUTF();
- long start = raf.getFilePointer();
- int cena = raf.readInt();
- int liczba_sztuk = raf.readInt();
- long stop = raf.getFilePointer();
- if(nazwa.equals(nazwa_towaru)) { ilosc_sztuk = liczba_sztuk; };
- if(liczba_sztuk >= 250){
- raf.seek(start);
- cena = (int)(cena * 0.9);
- raf.writeInt(cena);
- raf.seek(stop);
- }
- }
- raf.close();
- }catch(Exception e) {System.out.println("BÅÄ d: " + e); }
- return ilosc_sztuk;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement