Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Front_desk;
- import java.util.*;
- import java.util.stream.Collectors;
- import java.util.stream.Stream;
- import java.io.*;
- import java.lang.*;
- import java.nio.file.Files;
- import java.nio.file.Paths;
- public class AvailRoom {
- List<String> result = new ArrayList<>();
- String RoomNo;
- private Formatter x;
- void openFile () {
- try {
- x = new Formatter("Room");
- }
- catch(Exception e) {
- System.out.println("You have an error");
- }
- }
- void addRecord (String Num, String OccName) {
- x.format("%s - %s", Num, OccName);
- }
- void closefile() {
- x.close();
- }
- void addFileToList () {
- try (Stream<String> lines = Files.lines(Paths.get("Room"))) {
- result = lines.collect(Collectors.toList());
- }
- catch (Exception e) {
- System.out.println("it no work");
- }
- }
- void ListMod () {
- for (int index = 0; index< 25; index++) {
- if(result.get(index) == "o") {
- System.out.println(index+ " :this room is empty");
- System.out.println(index+ " do you want to add someone? [Y/N]");
- if (ans == y) {
- result.set(index, usrinput);
- }
- else {
- "okay"
- }
- }
- }
- }
- void AddListToFile() {
- File f = new File("Room");
- f.delete();
- try {
- x = new Formatter("Room");
- }
- catch(Exception e) {
- System.out.println("You have an error");
- }
- for (int index = 0; index< 25; index++) {
- x.format("%s - %s", result.get(index) );
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement