Advertisement
Guest User

Untitled

a guest
Apr 4th, 2020
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.47 KB | None | 0 0
  1. package Front_desk;
  2.  
  3. import java.util.*;
  4. import java.util.stream.Collectors;
  5. import java.util.stream.Stream;
  6. import java.io.*;
  7. import java.lang.*;
  8. import java.nio.file.Files;
  9. import java.nio.file.Paths;
  10.  
  11. public class AvailRoom {
  12.     List<String> result = new ArrayList<>();
  13.     String RoomNo;
  14.     private Formatter x;
  15.     void openFile () {
  16.        
  17.         try {
  18.             x = new Formatter("Room");
  19.         }
  20.        
  21.         catch(Exception e) {
  22.             System.out.println("You have an error");
  23.         }
  24.        
  25.     }
  26.    
  27.     void addRecord (String Num, String OccName) {
  28.         x.format("%s - %s", Num, OccName);
  29.     }
  30.    
  31.     void closefile() {
  32.         x.close();
  33.     }
  34.      
  35.     void addFileToList () {
  36.        
  37.         try (Stream<String> lines = Files.lines(Paths.get("Room"))) {
  38.             result = lines.collect(Collectors.toList());
  39.         }
  40.         catch (Exception e) {
  41.             System.out.println("it no work");
  42.         }
  43.     }
  44.  
  45.    
  46.     void ListMod () {
  47.         for (int index = 0; index< 25; index++) {
  48.            
  49.             if(result.get(index) == "o") {
  50.                 System.out.println(index+ " :this room is empty");
  51.                 System.out.println(index+ " do you want to add someone? [Y/N]");
  52.                
  53.                 if (ans == y) {
  54.                      result.set(index, usrinput);
  55.                 }
  56.                 else {
  57.                     "okay"
  58.                 }
  59.             }
  60.         }
  61.     }
  62.  
  63.     void AddListToFile() {
  64.         File f = new File("Room");
  65.         f.delete();
  66.        
  67.         try {
  68.             x = new Formatter("Room");
  69.         }
  70.        
  71.         catch(Exception e) {
  72.             System.out.println("You have an error");
  73.            
  74.         }
  75.        
  76.         for (int index = 0; index< 25; index++) {
  77.             x.format("%s - %s", result.get(index) );
  78.         }
  79.     }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement