diff --git a/src/main/java/me/alex4386/gachon/network/common/http/HttpRequest.java b/src/main/java/me/alex4386/gachon/network/common/http/HttpRequest.java new file mode 100644 index 0000000..1613f0c --- /dev/null +++ b/src/main/java/me/alex4386/gachon/network/common/http/HttpRequest.java @@ -0,0 +1,96 @@ +package me.alex4386.gachon.network.common.http; + +import java.io.IOException; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.net.HttpURLConnection; +import java.net.URL; +import java.util.HashMap; +import java.util.Map; + +public class HttpRequest { + // 귀찮으니까 학교 과제물 낸걸로 대충 때워 + // Removed JSON Dependencies Edition + + HttpRequestMethod method; + URL url; + + String body = null; + Map headers = new HashMap<>(); + + boolean enableDebug = false; + + public HttpRequest(HttpRequestMethod method, URL url) { + this.method = method; + this.url = url; + } + + public HttpRequest(HttpRequestMethod method, URL url, String contentType, String body) { + this.method = method; + this.url = url; + + this.body = body; + + headers.put("Content-Type", contentType); + } + + public void addHeaders(Map headers) { + for (Map.Entry header : headers.entrySet()) { + String key = header.getKey(); + + if (this.headers.containsKey(key)) { + this.headers.remove(key); + } + + this.headers.put(key, header.getValue()); + } + } + + public void setHeaders(Map headers) { + this.headers = headers; + } + + public boolean isDebug() { + return this.enableDebug; + } + + public void setDebug(boolean debug) { + this.enableDebug = debug; + } + + public HttpResponse getResponse() throws IOException { + HttpURLConnection conn = (HttpURLConnection) this.url.openConnection(); + conn.setRequestMethod(this.method.toString()); + + for (Map.Entry headerEntry : this.headers.entrySet()) { + conn.setRequestProperty(headerEntry.getKey(), headerEntry.getValue()); + } + + if (this.enableDebug) { + System.out.println(this.method.toString()+" "+this.url.toString()); + } + + if (body != null) { + if (this.enableDebug) { + System.out.println(body); + } + + conn.setDoOutput(true); + + OutputStream outputStream = conn.getOutputStream(); + OutputStreamWriter writer = new OutputStreamWriter(outputStream, "UTF-8"); + + writer.write(body); + + writer.flush(); + writer.close(); + } + + conn.connect(); + + HttpResponse response = new HttpResponse(conn); + + return response; + } +} + diff --git a/src/main/java/me/alex4386/gachon/network/common/http/HttpRequestMethod.java b/src/main/java/me/alex4386/gachon/network/common/http/HttpRequestMethod.java new file mode 100644 index 0000000..7f79b83 --- /dev/null +++ b/src/main/java/me/alex4386/gachon/network/common/http/HttpRequestMethod.java @@ -0,0 +1,23 @@ +package me.alex4386.gachon.network.common.http; + +public enum HttpRequestMethod { + GET("GET"), + HEAD("HEAD"), + POST("POST"), + PUT("PUT"), + PATCH("PATCH"), + DELETE("DELETE"), + OPTIONS("OPTIONS"), + TRACE("TRACE"); + + private String rawString; + + HttpRequestMethod(String raw) { + this.rawString = raw; + } + + @Override + public String toString() { + return this.rawString; + } +} \ No newline at end of file diff --git a/src/main/java/me/alex4386/gachon/network/common/http/HttpResponse.java b/src/main/java/me/alex4386/gachon/network/common/http/HttpResponse.java new file mode 100644 index 0000000..797cdb2 --- /dev/null +++ b/src/main/java/me/alex4386/gachon/network/common/http/HttpResponse.java @@ -0,0 +1,56 @@ +package me.alex4386.gachon.network.common.http; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.HttpURLConnection; + +public class HttpResponse { + public HttpResponseCode code; + public String response; + + boolean enableDebug = false; + + public HttpResponse(HttpURLConnection conn) throws IOException { + int responseCode = conn.getResponseCode(); + this.code = HttpResponseCode.getResponse(responseCode); + + BufferedReader bufReader; + + if (this.code.isOK()) { + bufReader = new BufferedReader( + new InputStreamReader( + conn.getInputStream() + ) + ); + } else { + bufReader = new BufferedReader( + new InputStreamReader( + conn.getErrorStream() + ) + ); + } + + StringBuilder stringBuilder = new StringBuilder(); + String thisLine; + while ((thisLine = bufReader.readLine()) != null) { + stringBuilder.append(thisLine); + stringBuilder.append("\n"); + } + + bufReader.close(); + conn.disconnect(); + + this.response = stringBuilder.toString(); + + if (this.enableDebug) { + System.out.println("Code: "+this.code.getCode()); + System.out.println("Resp: \n"+this.response); + } + } + + @Override + public String toString() { + return this.response; + } +} \ No newline at end of file diff --git a/src/main/java/me/alex4386/gachon/network/common/http/HttpResponseCode.java b/src/main/java/me/alex4386/gachon/network/common/http/HttpResponseCode.java new file mode 100644 index 0000000..22fb8c1 --- /dev/null +++ b/src/main/java/me/alex4386/gachon/network/common/http/HttpResponseCode.java @@ -0,0 +1,127 @@ +package me.alex4386.gachon.network.common.http; + +public enum HttpResponseCode { + /* Informational */ + CONTINUE(100, "Continue"), + SWITCHING_PROTOCOLS(101, "Switching Protocols"), + PROCESSING(102, "Processing"), + EARLY_HINTS(103, "Early Hints"), + + /* Success */ + OK(200, "OK"), + CREATED(201, "Created"), + ACCEPTED(202, "Accepted"), + NON_AUTHORITATIVE_INFORMATION(203, "Non-Authoritative Information"), + NO_CONTENT(204, "No Content"), + RESET_CONTENT(205, "Reset Content"), + PARTIAL_CONTENT(206, "Partial Content"), + MULTI_STATUS(207, "Multi-Status"), + ALREADY_REPORTED(208, "Already Reported"), + IM_USED(226, "IM Used"), + + /* Redirection */ + MULTIPLE_CHOICES(300, "Multiple Choices"), + MOVED_PERMANENTLY(301, "Moved Permanently"), + FOUND(302, "Found"), + SEE_OTHER(303, "See Other"), + NOT_MODIFIED(304, "Not Modified"), + USE_PROXY(305, "Use Proxy"), + TEMPORARY_REDIRECT(307, "Temporary Redirect"), + PERMANENT_REDIRECT(308, "Permanent Redirect"), + + /* Client Error */ + BAD_REQUEST(400, "Bad Request"), + UNAUTHORIZED(401, "Unauthorized"), + PAYMENT_REQUIRED(402, "Payment Required"), + FORBIDDEN(403, "Forbidden"), + NOT_FOUND(404, "Not Found"), + METHOD_NOT_ALLOWED(405, "Method Not Allowed"), + NOT_ACCEPTABLE(406, "Not Acceptable"), + PROXY_AUTHENTICATION_REQUIRED(407, "Proxy Authentication Required"), + REQUEST_TIMEOUT(408, "Request Timeout"), + CONFLICT(409, "Conflict"), + GONE(410, "Gone"), + LENGTH_REQUIRED(411, "Length Required"), + PRECONDITION_FAILED(412, "Precondition Failed"), + PAYLOAD_TOO_LARGE(413, "Payload Too Large"), + URI_TOO_LONG(414, "URI Too Long"), + UNSUPPORTED_MEDIA_TYPE(415, "Unsupported Media Type"), + REQUEST_RANGE_NOT_SATISFIABLE(416, "Request Range Not Satisfiable"), + EXPECTATION_FAILED(417, "Expectation Failed"), + IM_A_TEAPOT(418, "I'm a teapot"), + UNPROCESSABLE_ENTITY(422, "Unprocessable Entity"), + LOCKED(423, "Precondition Failed"), + FAILED_DEPENDENCY(424, "Precondition Failed"), + TOO_EARLY(425, "Too Early"), + UPGRADE_REQUIRED(426, "Upgrade Required"), + PRECONDITION_REQUIRED(428, "Precondition Required"), + TOO_MANY_REQUESTS(429, "Too Many Requests"), + REQUEST_HEADER_FIELDS_TOO_LARGE(431, "Request Header Fields Too Large"), + @Deprecated + NO_RESPONSE(444, "No Response"), + @Deprecated + RETRY_WITH(449, "Retry With"), + @Deprecated + BLOCKED_BY_WINDOWS_PARENTAL_CONTROLS(450, "Blocked by Windows Parental Controls"), + UNAVAILABLE_FOR_LEGAL_REASONS(451, "Precondition Failed"), + @Deprecated + CLIENT_CLOSED_REQUEST(499, "Client Closed Request"), + + /* Server Error */ + INTERNAL_SERVER_ERROR(500, "Internal Server Error"), + NOT_IMPLEMENTED(501, "Not Implemented"), + BAD_GATEWAY(502, "Bad Gateway"), + SERVICE_UNAVAILABLE(503, "Service Unavailable"), + GATEWAY_TIMEOUT(504, "Gateway Timeout"), + HTTP_VERSION_NOT_SUPPORTED(505, "HTTP Version Not Supported"), + VARIANT_ALSO_NEGOTIATES(506, "Variant Also Negotiates"), + INSUFFICIENT_STORAGE(507, "Insufficient Storage"), + LOOP_DETECTED(508, "Loop Detected"), + BANDWIDTH_LIMIT_EXCEEDED(509, "Bandwidth Limit Exceeded"), + NOT_EXTENDED(510, "Not Extended"), + NETWORK_AUTHENTICATION_REQUIRED(511, "Network Authentication Required"); + + private int code; + private String name; + + HttpResponseCode(int code, String name) { + this.code = code; + this.name = name; + } + + public boolean isOK() { + return code == 200; + } + + public boolean isSuccess() { + return 200 <= code && code < 300; + } + + public boolean isClientError() { + return 400 <= code && code < 499; + } + + public boolean isServerError() { + return 500 <= code && code < 599; + } + + public int getCode() { + return this.code; + } + + @Override + public String toString() { + return name; + } + + public static HttpResponseCode getResponse(int code) { + for (HttpResponseCode respCode : HttpResponseCode.values()) { + if (code == respCode.code) { + return respCode; + } + } + + return null; + } + +} \ No newline at end of file diff --git a/src/main/java/me/alex4386/gachon/sw14462/Main.java b/src/main/java/me/alex4386/gachon/sw14462/Main.java index e919e50..db42bd0 100644 --- a/src/main/java/me/alex4386/gachon/sw14462/Main.java +++ b/src/main/java/me/alex4386/gachon/sw14462/Main.java @@ -5,7 +5,7 @@ import java.util.*; public class Main { - public static String currentTarget = "day23"; + public static String currentTarget = "day24"; public static boolean fallbackToLatest = true; public static Map> getAvailableTargetClassNames() { diff --git a/src/main/java/me/alex4386/gachon/sw14462/day24/Main.java b/src/main/java/me/alex4386/gachon/sw14462/day24/Main.java new file mode 100644 index 0000000..8c05df7 --- /dev/null +++ b/src/main/java/me/alex4386/gachon/sw14462/day24/Main.java @@ -0,0 +1,19 @@ +package me.alex4386.gachon.sw14462.day24; + +import me.alex4386.gachon.sw14462.utils.Chainloader; + +public class Main { + public static String chainloadTarget = "ex13_9"; + + public static void main(String[] args) throws Throwable { + String packageName = Main.class.getPackage().getName(); + String chainLoadTargetClass = packageName + "." + chainloadTarget + ".Main"; + + try { + Chainloader.chainloadTarget(chainLoadTargetClass, args); + } catch (Exception e) { + throw e; + } + } + +} diff --git a/src/main/java/me/alex4386/gachon/sw14462/day24/ex13_2/Main.java b/src/main/java/me/alex4386/gachon/sw14462/day24/ex13_2/Main.java new file mode 100644 index 0000000..b959094 --- /dev/null +++ b/src/main/java/me/alex4386/gachon/sw14462/day24/ex13_2/Main.java @@ -0,0 +1,61 @@ +package me.alex4386.gachon.sw14462.day24.ex13_2; + +import java.io.File; +import java.io.PrintWriter; +import java.util.Scanner; + +public class Main { + public static void main(String[] args) { + File in = new File("in"); + File out = new File("out"); + + if (!in.exists()) { + System.err.println("File named 'in' not found"); + System.exit(1); + } + + if (out.exists()) { + out.delete(); + } + + try { + out.createNewFile(); + } catch (Exception e) { + System.err.println("Failed to create file: " + e.getMessage()); + return; + } + + // assume that the numbers in the input file are already ordered from smallest to largest: + // which means the number came beforehand is same with current number, it is a duplicate. + + // read the file + int prevInt = 0; + try { + Scanner scanner = new Scanner(in); + PrintWriter writer = new PrintWriter(out); + + boolean isFirst = true; + + while (scanner.hasNextInt()) { + int currentInt = scanner.nextInt(); + + if (isFirst) { + isFirst = false; + prevInt = currentInt; + writer.println(currentInt); + } else { + if (prevInt != currentInt) { + writer.println(currentInt); + prevInt = currentInt; + } + } + } + + scanner.close(); + writer.close(); + } catch (Exception e) { + System.err.println("Failed to read/write file: " + e.getMessage()); + return; + } + } +} diff --git a/src/main/java/me/alex4386/gachon/sw14462/day24/ex13_2a/Main.java b/src/main/java/me/alex4386/gachon/sw14462/day24/ex13_2a/Main.java new file mode 100644 index 0000000..b0ede3d --- /dev/null +++ b/src/main/java/me/alex4386/gachon/sw14462/day24/ex13_2a/Main.java @@ -0,0 +1,94 @@ +package me.alex4386.gachon.sw14462.day24.ex13_2a; + +import java.io.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Scanner; + +public class Main { + + public static void main(String[] args) { + Scanner scanner = new Scanner(System.in); + + System.out.print("Enter the filename: "); + String filename = scanner.nextLine(); + + // generate 10 random integer + int[] randomIntegers = new int[10]; + for (int i = 0; i < 10; i++) { + randomIntegers[i] = (int) (Math.random() * 1000); + } + + // write to file + File targetFile = new File(filename); + if (targetFile.exists()) { + // unlink the file + targetFile.delete(); + } + + FileOutputStream stream; + ObjectOutputStream writer; + try { + targetFile.createNewFile(); + stream = new FileOutputStream(targetFile); + writer = new ObjectOutputStream(stream); + } catch (Exception e) { + System.err.println("Failed to create file: " + e.getMessage()); + return; + } + + try { + writer.writeObject(randomIntegers); + } catch (IOException e) { + System.err.println("Failed to write object: " + e.getMessage()); + return; + } + + System.out.println("File created successfully."); + scanner.close(); + + // reopen the file + targetFile = new File(filename); + if (!targetFile.exists()) { + System.err.println("File does not exists, is the file has been deleted in the meantime?"); + return; + } + + try { + scanner = new Scanner(targetFile); + } catch (Exception e) { + System.err.println("Failed to open file: " + e.getMessage()); + return; + } + + int[] readIntegers = null; + try { + FileInputStream fileInputStream = new FileInputStream(targetFile); + ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream); + readIntegers = (int[]) objectInputStream.readObject(); + objectInputStream.close(); + } catch (Exception e) { + System.err.println("Failed to read object: " + e.getMessage()); + return; + } + + int count = 0; + int min = Integer.MAX_VALUE, max = Integer.MIN_VALUE, sum = 0; + double average; + + for (int val : readIntegers) { + count++; + sum += val; + if (val < min) min = val; + if (val > max) max = val; + } + + average = (double) sum / count; + scanner.close(); + + System.out.println("min: "+min); + System.out.println("max: "+max); + System.out.println("sum: "+sum); + System.out.println("average: "+average); + } +} diff --git a/src/main/java/me/alex4386/gachon/sw14462/day24/ex13_2b/Main.java b/src/main/java/me/alex4386/gachon/sw14462/day24/ex13_2b/Main.java new file mode 100644 index 0000000..7665241 --- /dev/null +++ b/src/main/java/me/alex4386/gachon/sw14462/day24/ex13_2b/Main.java @@ -0,0 +1,120 @@ +package me.alex4386.gachon.sw14462.day24.ex13_2b; + +import java.io.*; +import java.util.Scanner; + +public class Main { + public static void main(String[] args) { + File signalFile = new File("signal.txt"); + if (!signalFile.exists()) { + System.err.println("Signal file not found: signal.txt"); + System.exit(1); + } + + int[] readIntegers = new int[10]; + FileInputStream stream; + Scanner scanner; + try { + stream = new FileInputStream(signalFile); + scanner = new Scanner(stream); + } catch (Exception e) { + System.err.println("Failed to open file: " + e.getMessage()); + return; + } + + try { + for (int i = 0; i < 10; i++) { + readIntegers[i] = scanner.nextInt(); + } + } catch (Exception e) { + System.err.println("Failed to read file: " + e.getMessage()); + return; + } + + scanner.close(); + + File outputFile = new File("signal.out"); + if (outputFile.exists()) { + outputFile.delete(); + } + + FileOutputStream outputStream; + try { + outputFile.createNewFile(); + outputStream = new FileOutputStream(outputFile); + } catch (Exception e) { + System.err.println("Failed to create file: " + e.getMessage()); + return; + } + + ObjectOutputStream objOutStream; + int[] diffIntegers = new int[10]; + diffIntegers[0] = readIntegers[0]; + for (int i = 1; i < 10; i++) { + int diff = readIntegers[i] - readIntegers[i - 1]; + if (diff > 128 || diff < -127) { + System.err.println("Value out of range: " + diff); + return; + } + + diffIntegers[i] = diff; + } + + try { + objOutStream = new ObjectOutputStream(outputStream); + objOutStream.writeObject(diffIntegers); + } catch (Exception e) { + System.err.println("Failed to write object: " + e.getMessage()); + return; + } + + try { + objOutStream.close(); + } catch (Exception e) { + System.err.println("Failed to close file: " + e.getMessage()); + return; + } + + File targetFile = new File("signal.exp"); + try { + if (!targetFile.exists()) { + targetFile.createNewFile(); + } else { + targetFile.delete(); + targetFile.createNewFile(); + } + } catch (IOException e) { + System.err.println("Failed to create file: " + e.getMessage()); + return; + } + + // read back + FileInputStream fileInputStream; + ObjectInputStream objInStream; + + try { + fileInputStream = new FileInputStream(outputFile); + objInStream = new ObjectInputStream(fileInputStream); + } catch (Exception e) { + System.err.println("Failed to open file: " + e.getMessage()); + return; + } + + int[] exportedIntegers = null; + try { + exportedIntegers = (int[]) objInStream.readObject(); + } catch (Exception e) { + System.err.println("Failed to read object: " + e.getMessage()); + return; + } + + // process exported integers + for (int i = 1; i < 10; i++) { + exportedIntegers[i] += exportedIntegers[i - 1]; + } + + for (int i = 0; i < 10; i++) { + System.out.println(exportedIntegers[i]); + } + } +} diff --git a/src/main/java/me/alex4386/gachon/sw14462/day24/ex13_3/Main.java b/src/main/java/me/alex4386/gachon/sw14462/day24/ex13_3/Main.java new file mode 100644 index 0000000..8c9674b --- /dev/null +++ b/src/main/java/me/alex4386/gachon/sw14462/day24/ex13_3/Main.java @@ -0,0 +1,32 @@ +package me.alex4386.gachon.sw14462.day24.ex13_3; + +import java.io.File; +import java.io.IOException; +import java.util.Scanner; + +public class Main { + public static void main(String[] args) { + File wordFile = new File("words.txt"); + + if (!wordFile.exists()) { + System.err.println("Word file not found: words.txt"); + System.exit(1); + } + + Scanner scanner; + try { + scanner = new Scanner(wordFile); + } catch(IOException e) { + System.err.println("Failed to open file: " + e.getMessage()); + return; + } + + while (scanner.hasNextLine()) { + String word = scanner.nextLine(); + if (word.endsWith("dous")) { + System.out.println(word); + } + } + + } +} diff --git a/src/main/java/me/alex4386/gachon/sw14462/day24/ex13_5/Main.java b/src/main/java/me/alex4386/gachon/sw14462/day24/ex13_5/Main.java new file mode 100644 index 0000000..ec59490 --- /dev/null +++ b/src/main/java/me/alex4386/gachon/sw14462/day24/ex13_5/Main.java @@ -0,0 +1,54 @@ +package me.alex4386.gachon.sw14462.day24.ex13_5; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; +import java.util.Scanner; + +public class Main { + public static void main(String[] args) { + File abbreviationFile = new File("abbreviations.txt"); + if (!abbreviationFile.exists()) { + System.err.println("Abbreviation file not found: abbreviations.txt"); + System.err.println("Falling back to jar file internal..."); + + System.exit(1); + } + + File chatFile = new File("chat.txt"); + if (!chatFile.exists()) { + System.err.println("Chat file not found: chat.txt"); + System.exit(1); + } + + // wrap words (seperated by line) specified in abbreviations file with <> in chat file + List abbreviations = new ArrayList<>(); + try { + Scanner scanner = new Scanner(abbreviationFile); + while (scanner.hasNextLine()) { + abbreviations.add(scanner.nextLine()); + } + scanner.close(); + } catch (Exception e) { + System.err.println("Failed to read abbreviations file: " + e.getMessage()); + return; + } + + try { + Scanner scanner = new Scanner(chatFile); + while (scanner.hasNextLine()) { + String line = scanner.nextLine(); + for (String abbreviation : abbreviations) { + // escape regex for special characters + String abbreviationEscaped = abbreviation.replaceAll("([\\[\\]\\{\\}\\(\\)\\*\\+\\?\\^\\$\\.\\|])", "\\\\$1"); + line = line.replaceAll(abbreviationEscaped, "<" + abbreviation + ">"); + } + System.out.println(line); + } + scanner.close(); + } catch (Exception e) { + System.err.println("Failed to read chat file: " + e.getMessage()); + return; + } + } +} diff --git a/src/main/java/me/alex4386/gachon/sw14462/day24/ex13_9/Main.java b/src/main/java/me/alex4386/gachon/sw14462/day24/ex13_9/Main.java new file mode 100644 index 0000000..2ec2244 --- /dev/null +++ b/src/main/java/me/alex4386/gachon/sw14462/day24/ex13_9/Main.java @@ -0,0 +1,64 @@ +package me.alex4386.gachon.sw14462.day24.ex13_9; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.Scanner; + +public class Main { + public static void main(String[] args) { + InputStream stream; + File file = new File("haberman.csv"); + try { + stream = new FileInputStream(file); + } catch (IOException e) { + System.err.println("Failed to load following file: haberman.csv"); + System.err.println("Fallback to jar file..."); + + stream = Main.class.getResourceAsStream("/day24/ex13_9/haberman.csv"); + if (stream == null) { + System.err.println("Failed to load following resource from jar file: haberman.csv"); + return; + } + } + + Scanner scanner = new Scanner(stream); + List data = new ArrayList<>(); + + while (scanner.hasNextLine()) { + String csv = scanner.nextLine(); + SurgeryData surgeryData = SurgeryData.fromCSV(csv); + if (surgeryData != null) { + data.add(surgeryData); + } + } + + // calculates the average number of positive axillary nodes detected for + // patients who survived 5 years or longer + int totalNodes = 0; + int totalPatients = 0; + for (SurgeryData surgeryData : data) { + if (surgeryData.getSurvival() == 1) { + totalNodes += surgeryData.getNodes(); + totalPatients++; + } + } + + System.out.println("Average number of positive axillary nodes detected for patients who survived 5 years or longer: " + (totalNodes / totalPatients)); + + // the average number of positive axillary nodes detected for patients who died within 5 years + totalNodes = 0; + totalPatients = 0; + for (SurgeryData surgeryData : data) { + if (surgeryData.getSurvival() == 2) { + totalNodes += surgeryData.getNodes(); + totalPatients++; + } + } + + System.out.println("Average number of positive axillary nodes detected for patients who died within 5 years: " + (totalNodes / totalPatients)); + } +} diff --git a/src/main/java/me/alex4386/gachon/sw14462/day24/ex13_9/SurgeryData.java b/src/main/java/me/alex4386/gachon/sw14462/day24/ex13_9/SurgeryData.java new file mode 100644 index 0000000..4874e6f --- /dev/null +++ b/src/main/java/me/alex4386/gachon/sw14462/day24/ex13_9/SurgeryData.java @@ -0,0 +1,41 @@ +package me.alex4386.gachon.sw14462.day24.ex13_9; + +public class SurgeryData { + private int age; + private int year; + private int nodes; + private int survival; + + public SurgeryData(int age, int year, int nodes, int survival) { + this.age = age; + this.year = year; + this.nodes = nodes; + this.survival = survival; + } + + public static SurgeryData fromCSV(String csv) { + String[] data = csv.split(","); + return new SurgeryData( + Integer.parseInt(data[0]), + Integer.parseInt(data[1]), + Integer.parseInt(data[2]), + Integer.parseInt(data[3]) + ); + } + + public int getAge() { + return age; + } + + public int getYear() { + return year; + } + + public int getNodes() { + return nodes; + } + + public int getSurvival() { + return survival; + } +} diff --git a/src/main/resources/day24/ex13_9/haberman.csv b/src/main/resources/day24/ex13_9/haberman.csv new file mode 100755 index 0000000..1052439 --- /dev/null +++ b/src/main/resources/day24/ex13_9/haberman.csv @@ -0,0 +1,306 @@ +30,64,1,1 +30,62,3,1 +30,65,0,1 +31,59,2,1 +31,65,4,1 +33,58,10,1 +33,60,0,1 +34,59,0,2 +34,66,9,2 +34,58,30,1 +34,60,1,1 +34,61,10,1 +34,67,7,1 +34,60,0,1 +35,64,13,1 +35,63,0,1 +36,60,1,1 +36,69,0,1 +37,60,0,1 +37,63,0,1 +37,58,0,1 +37,59,6,1 +37,60,15,1 +37,63,0,1 +38,69,21,2 +38,59,2,1 +38,60,0,1 +38,60,0,1 +38,62,3,1 +38,64,1,1 +38,66,0,1 +38,66,11,1 +38,60,1,1 +38,67,5,1 +39,66,0,2 +39,63,0,1 +39,67,0,1 +39,58,0,1 +39,59,2,1 +39,63,4,1 +40,58,2,1 +40,58,0,1 +40,65,0,1 +41,60,23,2 +41,64,0,2 +41,67,0,2 +41,58,0,1 +41,59,8,1 +41,59,0,1 +41,64,0,1 +41,69,8,1 +41,65,0,1 +41,65,0,1 +42,69,1,2 +42,59,0,2 +42,58,0,1 +42,60,1,1 +42,59,2,1 +42,61,4,1 +42,62,20,1 +42,65,0,1 +42,63,1,1 +43,58,52,2 +43,59,2,2 +43,64,0,2 +43,64,0,2 +43,63,14,1 +43,64,2,1 +43,64,3,1 +43,60,0,1 +43,63,2,1 +43,65,0,1 +43,66,4,1 +44,64,6,2 +44,58,9,2 +44,63,19,2 +44,61,0,1 +44,63,1,1 +44,61,0,1 +44,67,16,1 +45,65,6,2 +45,66,0,2 +45,67,1,2 +45,60,0,1 +45,67,0,1 +45,59,14,1 +45,64,0,1 +45,68,0,1 +45,67,1,1 +46,58,2,2 +46,69,3,2 +46,62,5,2 +46,65,20,2 +46,62,0,1 +46,58,3,1 +46,63,0,1 +47,63,23,2 +47,62,0,2 +47,65,0,2 +47,61,0,1 +47,63,6,1 +47,66,0,1 +47,67,0,1 +47,58,3,1 +47,60,4,1 +47,68,4,1 +47,66,12,1 +48,58,11,2 +48,58,11,2 +48,67,7,2 +48,61,8,1 +48,62,2,1 +48,64,0,1 +48,66,0,1 +49,63,0,2 +49,64,10,2 +49,61,1,1 +49,62,0,1 +49,66,0,1 +49,60,1,1 +49,62,1,1 +49,63,3,1 +49,61,0,1 +49,67,1,1 +50,63,13,2 +50,64,0,2 +50,59,0,1 +50,61,6,1 +50,61,0,1 +50,63,1,1 +50,58,1,1 +50,59,2,1 +50,61,0,1 +50,64,0,1 +50,65,4,1 +50,66,1,1 +51,59,13,2 +51,59,3,2 +51,64,7,1 +51,59,1,1 +51,65,0,1 +51,66,1,1 +52,69,3,2 +52,59,2,2 +52,62,3,2 +52,66,4,2 +52,61,0,1 +52,63,4,1 +52,69,0,1 +52,60,4,1 +52,60,5,1 +52,62,0,1 +52,62,1,1 +52,64,0,1 +52,65,0,1 +52,68,0,1 +53,58,4,2 +53,65,1,2 +53,59,3,2 +53,60,9,2 +53,63,24,2 +53,65,12,2 +53,58,1,1 +53,60,1,1 +53,60,2,1 +53,61,1,1 +53,63,0,1 +54,60,11,2 +54,65,23,2 +54,65,5,2 +54,68,7,2 +54,59,7,1 +54,60,3,1 +54,66,0,1 +54,67,46,1 +54,62,0,1 +54,69,7,1 +54,63,19,1 +54,58,1,1 +54,62,0,1 +55,63,6,2 +55,68,15,2 +55,58,1,1 +55,58,0,1 +55,58,1,1 +55,66,18,1 +55,66,0,1 +55,69,3,1 +55,69,22,1 +55,67,1,1 +56,65,9,2 +56,66,3,2 +56,60,0,1 +56,66,2,1 +56,66,1,1 +56,67,0,1 +56,60,0,1 +57,61,5,2 +57,62,14,2 +57,64,1,2 +57,64,9,1 +57,69,0,1 +57,61,0,1 +57,62,0,1 +57,63,0,1 +57,64,0,1 +57,64,0,1 +57,67,0,1 +58,59,0,1 +58,60,3,1 +58,61,1,1 +58,67,0,1 +58,58,0,1 +58,58,3,1 +58,61,2,1 +59,62,35,2 +59,60,0,1 +59,63,0,1 +59,64,1,1 +59,64,4,1 +59,64,0,1 +59,64,7,1 +59,67,3,1 +60,59,17,2 +60,65,0,2 +60,61,1,1 +60,67,2,1 +60,61,25,1 +60,64,0,1 +61,62,5,2 +61,65,0,2 +61,68,1,2 +61,59,0,1 +61,59,0,1 +61,64,0,1 +61,65,8,1 +61,68,0,1 +61,59,0,1 +62,59,13,2 +62,58,0,2 +62,65,19,2 +62,62,6,1 +62,66,0,1 +62,66,0,1 +62,58,0,1 +63,60,1,2 +63,61,0,1 +63,62,0,1 +63,63,0,1 +63,63,0,1 +63,66,0,1 +63,61,9,1 +63,61,28,1 +64,58,0,1 +64,65,22,1 +64,66,0,1 +64,61,0,1 +64,68,0,1 +65,58,0,2 +65,61,2,2 +65,62,22,2 +65,66,15,2 +65,58,0,1 +65,64,0,1 +65,67,0,1 +65,59,2,1 +65,64,0,1 +65,67,1,1 +66,58,0,2 +66,61,13,2 +66,58,0,1 +66,58,1,1 +66,68,0,1 +67,64,8,2 +67,63,1,2 +67,66,0,1 +67,66,0,1 +67,61,0,1 +67,65,0,1 +68,67,0,1 +68,68,0,1 +69,67,8,2 +69,60,0,1 +69,65,0,1 +69,66,0,1 +70,58,0,2 +70,58,4,2 +70,66,14,1 +70,67,0,1 +70,68,0,1 +70,59,8,1 +70,63,0,1 +71,68,2,1 +72,63,0,2 +72,58,0,1 +72,64,0,1 +72,67,3,1 +73,62,0,1 +73,68,0,1 +74,65,3,2 +74,63,0,1 +75,62,1,1 +76,67,0,1 +77,65,3,1 +78,65,1,2 +83,58,2,2