package se.kth.id2212.project.fish;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

public class Client {

    private static final String DEFAULT_SHARED_FILE_PATH = "shared";
    private static final String DEFAULT_SERVER_ADDRESS = "localhost";
    private static final String DEFAULT_SERVER_PORT = "69198"; // FISH => 6-9-19-8

    private String sharedFilePath, serverAddress, serverPort;

    public Client(String sharedFilePath, String serverAddress, String serverPort) {
        if (sharedFilePath != null) {
            this.sharedFilePath = sharedFilePath;
        } else {
            this.sharedFilePath = DEFAULT_SHARED_FILE_PATH;
        }
        if (serverAddress != null) {
            this.serverAddress = serverAddress;
        } else {
            this.serverAddress = DEFAULT_SERVER_ADDRESS;
        }
        if (serverPort != null) {
            this.serverPort = serverPort;
        } else {
            this.serverPort = DEFAULT_SERVER_PORT;
        }
    }

    public void run() {
        System.out.println("Client started.\n   path | " + sharedFilePath +
                "\naddress | " + serverAddress + "\n   port | " + serverPort);
        List<File> fileList = getFileList();
        // TODO: Implement a Client-Server protocol
        exchangeFileLists();
    }

    private List<File> getFileList() {
        ArrayList<File> ret = new ArrayList<>();

        System.out.println("\nShared files:");
        File dir = new File(sharedFilePath);
        dir.mkdir();
        File[] files = dir.listFiles();
        for (File f : files) {
            if (f.isFile()) {
                System.out.println(f.getName());
                ret.add(f);
            }
        }

        return ret;
    }

    private void exchangeFileLists() {

    }

    public static void main(String[] args) {
        new Client(args[0], args[1], args[2]).run();
    }
}

@@ -322,18 +322,17 @@
 RT = %2269
-19
+5
 8%22; // F
@@ -332,17 +332,17 @@
 %22; // FI
-S
+5
 H =%3E 6-9
@@ -346,10 +346,9 @@
 6-9-
-19
+5
 -8%0A%0A
@@ -1051,17 +1051,22 @@
 rintln(%22
-C
+FISH c
 lient st
@@ -1196,20 +1196,22 @@
    List%3C
-File
+String
 %3E fileLi
@@ -1286,37 +1286,8 @@
 col%0A
-        exchangeFileLists();%0A
     
@@ -1306,20 +1306,22 @@
 te List%3C
-File
+String
 %3E getFil
@@ -1348,20 +1348,22 @@
 rayList%3C
-File
+String
 %3E ret = 
@@ -1670,16 +1670,26 @@
 et.add(f
+.getName()
 );%0A     
@@ -1739,55 +1739,8 @@
  %7D%0A%0A
-    private void exchangeFileLists() %7B%0A%0A    %7D%0A%0A
     

Change File list to String list