Fargus811 / Competition

0 stars 0 forks source link

FileConfigurator.java ; filesExist() method #20

Closed VladOsipov closed 4 years ago

VladOsipov commented 4 years ago

The method below looks loke it checks if file exists and return the result of this check. But inside this method you create files (it's not expected)

public boolean filesExist()
VladOsipov commented 4 years ago

And I didn't find any place where you use the result of this method. Why isn't it void ?

VladOsipov commented 4 years ago

Also, please take a look at this code blocks

        coachFile = new File(dirPath + File.separator + "coachList.txt");
        if (!coachFile.exists()) {
            try {
                created = coachFile.createNewFile();
            } catch (IOException e) {
                System.err.println("FileConfigurator.fileExist(); Coach file cannot be created");
                e.printStackTrace();
            }
        }
        sportsmenFile = new File(dirPath + File.separator + "sportsmenList.txt");
        if (!sportsmenFile.exists()) {
            try {
                created = sportsmenFile.createNewFile();
            } catch (IOException e) {
                System.err.println("FileConfigurator.fileExist(); Coach file cannot be created");
                e.printStackTrace();
            }
        }
        allUsersFile = new File(dirPath + File.separator + "allUsersFileList.txt");
        if (!allUsersFile.exists()) {
            try {
                created = allUsersFile.createNewFile();
            } catch (IOException e) {
                System.err.println("FileConfigurator.fileExist(); Coach file cannot be created");
                e.printStackTrace();
            }
        }

What do you think about this blocks?

Fargus811 commented 4 years ago

Done.