Advertisement
leniuch

domki

Feb 25th, 2020
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.79 KB | None | 0 0
  1. public class domki {
  2.  
  3.     static String zmniejsz(String plik){
  4.     String nazwDom="";
  5.     int max = 0;
  6.    
  7.     try{
  8.         RandomAccessFile raf = new RandomAccessFile(plik, "rw");
  9.     String line;
  10.    
  11.     while( (line=raf.readLine())!=null ){
  12.     String nazwa = line;
  13.     int IKondygn = Integer.parseInt(raf.readLine());
  14.     long pos1 = raf.getFilePointer();
  15.     double cena = Double.parseDouble(raf.readLine());
  16.     long pos2 = raf.getFilePointer();
  17.    
  18.     if(IKondygn==1) {
  19.         cena*=0.9;
  20.         raf.seek(pos1);
  21.         raf.writeBytes(Double.toString(cena));
  22.         raf.seek(pos2);
  23.     }
  24.     if (IKondygn>max) {max=IKondygn; nazwDom = nazwa;}
  25.    
  26.     }
  27.     raf.close();
  28.     }
  29.     catch(IOException e) {System.out.println(e);};
  30.    
  31.    
  32.    
  33.     return nazwDom;}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement