diff --git a/Seminar 1/JavaOOPExample/.idea/misc.xml b/Seminar 1/JavaOOPExample/.idea/misc.xml new file mode 100644 index 0000000..e0844bc --- /dev/null +++ b/Seminar 1/JavaOOPExample/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Seminar 1/JavaOOPExample/.idea/modules.xml b/Seminar 1/JavaOOPExample/.idea/modules.xml new file mode 100644 index 0000000..2b9bbcd --- /dev/null +++ b/Seminar 1/JavaOOPExample/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Seminar 1/JavaOOPExample/.idea/vcs.xml b/Seminar 1/JavaOOPExample/.idea/vcs.xml new file mode 100644 index 0000000..b2bdec2 --- /dev/null +++ b/Seminar 1/JavaOOPExample/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Seminar 1/JavaOOPExample/.idea/workspace.xml b/Seminar 1/JavaOOPExample/.idea/workspace.xml new file mode 100644 index 0000000..824fdca --- /dev/null +++ b/Seminar 1/JavaOOPExample/.idea/workspace.xml @@ -0,0 +1,106 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + { + "keyToString": { + "RunOnceActivity.OpenProjectViewOnStart": "true", + "RunOnceActivity.ShowReadmeOnStart": "true", + "WebServerToolWindowFactoryState": "false", + "last_opened_file_path": "C:/Users/anyti/IdeaProjects/LeeChanMi/Seminar 1/JavaOOPExample/src/Class", + "node.js.detected.package.eslint": "true", + "node.js.detected.package.tslint": "true", + "node.js.selected.package.eslint": "(autodetect)", + "node.js.selected.package.tslint": "(autodetect)", + "vue.rearranger.settings.migration": "true" + } +} + + + + + + + + + + + + + + + + + + + 1680923658024 + + + + + + \ No newline at end of file diff --git a/Seminar 1/JavaOOPExample/JavaOOPExample.iml b/Seminar 1/JavaOOPExample/JavaOOPExample.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/Seminar 1/JavaOOPExample/JavaOOPExample.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Seminar 1/JavaOOPExample/src/AbstractClass/Car.java b/Seminar 1/JavaOOPExample/src/AbstractClass/Car.java new file mode 100644 index 0000000..cb96187 --- /dev/null +++ b/Seminar 1/JavaOOPExample/src/AbstractClass/Car.java @@ -0,0 +1,25 @@ +package AbstractClass; + +public abstract class Car { + private String type; + private double fuelEfficiency; + private double oilAmount; + + public Car(String type, double fuelEfficiency, double oilAmount) { + this.type = type; + this.fuelEfficiency = fuelEfficiency; + this.oilAmount = oilAmount; + } + + public abstract void go(); + + public abstract void stop(); + + public void fuelUp(int amount) { + this.oilAmount += (double)amount; + } + + public void fuelUp(double amount) { + this.oilAmount += amount; + } +} diff --git a/Seminar 1/JavaOOPExample/src/Class/Avante.java b/Seminar 1/JavaOOPExample/src/Class/Avante.java new file mode 100644 index 0000000..0dfddb8 --- /dev/null +++ b/Seminar 1/JavaOOPExample/src/Class/Avante.java @@ -0,0 +1,24 @@ +package Class; + +import AbstractClass.Car; + +public class Avante extends Car { + private int price; + + public Avante(String type, double fuelEfficiency, double oilAmount, int price) { + super(type, fuelEfficiency, oilAmount); + this.price = price; + } + + public void go() { + System.out.println("아반떼 주행하다"); + } + + public void stop() { + System.out.println("아반떼 정지하다"); + } + + public void goBack() { + System.out.println("후진하다"); + } +} diff --git a/Seminar 1/JavaOOPExample/src/Class/Box.java b/Seminar 1/JavaOOPExample/src/Class/Box.java new file mode 100644 index 0000000..8b724da --- /dev/null +++ b/Seminar 1/JavaOOPExample/src/Class/Box.java @@ -0,0 +1,19 @@ +package Class; + +public class Box { + private E[] contents; + private V amount; + + public Box(E[] contents, V amount) { + this.contents = contents; + this.amount = amount; + } + + public E[] getContents() { + return this.contents; + } + + public V getAmount() { + return this.amount; + } +} diff --git a/Seminar 1/JavaOOPExample/src/Class/Ferrari.java b/Seminar 1/JavaOOPExample/src/Class/Ferrari.java new file mode 100644 index 0000000..5180cb0 --- /dev/null +++ b/Seminar 1/JavaOOPExample/src/Class/Ferrari.java @@ -0,0 +1,31 @@ +package Class; + +import Interface.SportsCar; + +public class Ferrari implements SportsCar { + private int maxSpeed; + + public Ferrari(int maxSpeed) { + maxSpeed = this.maxSpeed; + } + + public void go() { + System.out.println("페라리 주행하다"); + } + + public void stop() { + System.out.println("페라리 정지하다"); + } + + public void drift() { + System.out.println("드리프트!!"); + } + + public void open() { + System.out.println("차량커버 열기"); + } + + public void close() { + System.out.println("차량커버 닫기"); + } +} \ No newline at end of file diff --git a/Seminar 1/JavaOOPExample/src/Class/Morning.java b/Seminar 1/JavaOOPExample/src/Class/Morning.java new file mode 100644 index 0000000..0dccda5 --- /dev/null +++ b/Seminar 1/JavaOOPExample/src/Class/Morning.java @@ -0,0 +1,24 @@ +package Class; + +import AbstractClass.Car; + +public class Morning extends Car { + private int price; + + public Morning(String type, double fuelEfficiency, double oilAmount, int price) { + super(type, fuelEfficiency, oilAmount); + this.price = price; + } + + public void go() { + System.out.println("모닝 주행하다"); + } + + public void stop() { + System.out.println("모닝 정지하다"); + } + + public void goBack() { + System.out.println("후진하다"); + } +} diff --git a/Seminar 1/JavaOOPExample/src/Interface/Car.java b/Seminar 1/JavaOOPExample/src/Interface/Car.java new file mode 100644 index 0000000..900a89e --- /dev/null +++ b/Seminar 1/JavaOOPExample/src/Interface/Car.java @@ -0,0 +1,7 @@ +package Interface; + +public interface Car { + void go(); + + void stop(); +} \ No newline at end of file diff --git a/Seminar 1/JavaOOPExample/src/Interface/SportsCar.java b/Seminar 1/JavaOOPExample/src/Interface/SportsCar.java new file mode 100644 index 0000000..b74b762 --- /dev/null +++ b/Seminar 1/JavaOOPExample/src/Interface/SportsCar.java @@ -0,0 +1,5 @@ +package Interface; + +public interface SportsCar extends Car { + void drift(); +} \ No newline at end of file diff --git a/Seminar 1/JavaOOPExample/src/Main.java b/Seminar 1/JavaOOPExample/src/Main.java new file mode 100644 index 0000000..2010c56 --- /dev/null +++ b/Seminar 1/JavaOOPExample/src/Main.java @@ -0,0 +1,30 @@ +import Class.Box; +import Class.Ferrari; +import Class.Morning; +import Class.Avante; +import AbstractClass.Car; + +public class Main { + public static void main(String[] args) { + Avante avante = new Avante("mid size", 15.2, 122.0, 19600000); + Morning morning = new Morning("small size", 12.7, 35.0, 9000000); + go(avante); + go(morning); + Ferrari ferrari = new Ferrari(330); + ferrari.go(); + ferrari.drift(); + Box box = new Box(new String[]{"인형", "태블릿", "노트북"}, 3); + printArray((String[])box.getContents()); + } + + public static void printArray(T[] array) { + for(T element : array) { + System.out.println(element); + } + } + + public static void go(Car car) { + car.go(); + } +} + diff --git a/Seminar1/JavaOOPExample/.idea/misc.xml b/Seminar1/JavaOOPExample/.idea/misc.xml new file mode 100644 index 0000000..e0844bc --- /dev/null +++ b/Seminar1/JavaOOPExample/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Seminar1/JavaOOPExample/.idea/modules.xml b/Seminar1/JavaOOPExample/.idea/modules.xml new file mode 100644 index 0000000..2b9bbcd --- /dev/null +++ b/Seminar1/JavaOOPExample/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Seminar1/JavaOOPExample/.idea/vcs.xml b/Seminar1/JavaOOPExample/.idea/vcs.xml new file mode 100644 index 0000000..b2bdec2 --- /dev/null +++ b/Seminar1/JavaOOPExample/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Seminar1/JavaOOPExample/.idea/workspace.xml b/Seminar1/JavaOOPExample/.idea/workspace.xml new file mode 100644 index 0000000..18f11d4 --- /dev/null +++ b/Seminar1/JavaOOPExample/.idea/workspace.xml @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + + + + + { + "keyToString": { + "RunOnceActivity.OpenProjectViewOnStart": "true", + "RunOnceActivity.ShowReadmeOnStart": "true", + "WebServerToolWindowFactoryState": "false", + "last_opened_file_path": "C:/Users/anyti/IdeaProjects/LeeChanMi/Seminar 1/JavaOOPExample/src/Class", + "node.js.detected.package.eslint": "true", + "node.js.detected.package.tslint": "true", + "node.js.selected.package.eslint": "(autodetect)", + "node.js.selected.package.tslint": "(autodetect)", + "vue.rearranger.settings.migration": "true" + } +} + + + + + + + + + + + + + + + + + + + 1680923658024 + + + + + + \ No newline at end of file diff --git a/Seminar1/JavaOOPExample/JavaOOPExample.iml b/Seminar1/JavaOOPExample/JavaOOPExample.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/Seminar1/JavaOOPExample/JavaOOPExample.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Seminar1/JavaOOPExample/src/AbstractClass/Car.java b/Seminar1/JavaOOPExample/src/AbstractClass/Car.java new file mode 100644 index 0000000..cb96187 --- /dev/null +++ b/Seminar1/JavaOOPExample/src/AbstractClass/Car.java @@ -0,0 +1,25 @@ +package AbstractClass; + +public abstract class Car { + private String type; + private double fuelEfficiency; + private double oilAmount; + + public Car(String type, double fuelEfficiency, double oilAmount) { + this.type = type; + this.fuelEfficiency = fuelEfficiency; + this.oilAmount = oilAmount; + } + + public abstract void go(); + + public abstract void stop(); + + public void fuelUp(int amount) { + this.oilAmount += (double)amount; + } + + public void fuelUp(double amount) { + this.oilAmount += amount; + } +} diff --git a/Seminar1/JavaOOPExample/src/Class/Avante.java b/Seminar1/JavaOOPExample/src/Class/Avante.java new file mode 100644 index 0000000..0dfddb8 --- /dev/null +++ b/Seminar1/JavaOOPExample/src/Class/Avante.java @@ -0,0 +1,24 @@ +package Class; + +import AbstractClass.Car; + +public class Avante extends Car { + private int price; + + public Avante(String type, double fuelEfficiency, double oilAmount, int price) { + super(type, fuelEfficiency, oilAmount); + this.price = price; + } + + public void go() { + System.out.println("아반떼 주행하다"); + } + + public void stop() { + System.out.println("아반떼 정지하다"); + } + + public void goBack() { + System.out.println("후진하다"); + } +} diff --git a/Seminar1/JavaOOPExample/src/Class/Box.java b/Seminar1/JavaOOPExample/src/Class/Box.java new file mode 100644 index 0000000..8b724da --- /dev/null +++ b/Seminar1/JavaOOPExample/src/Class/Box.java @@ -0,0 +1,19 @@ +package Class; + +public class Box { + private E[] contents; + private V amount; + + public Box(E[] contents, V amount) { + this.contents = contents; + this.amount = amount; + } + + public E[] getContents() { + return this.contents; + } + + public V getAmount() { + return this.amount; + } +} diff --git a/Seminar1/JavaOOPExample/src/Class/Ferrari.java b/Seminar1/JavaOOPExample/src/Class/Ferrari.java new file mode 100644 index 0000000..5180cb0 --- /dev/null +++ b/Seminar1/JavaOOPExample/src/Class/Ferrari.java @@ -0,0 +1,31 @@ +package Class; + +import Interface.SportsCar; + +public class Ferrari implements SportsCar { + private int maxSpeed; + + public Ferrari(int maxSpeed) { + maxSpeed = this.maxSpeed; + } + + public void go() { + System.out.println("페라리 주행하다"); + } + + public void stop() { + System.out.println("페라리 정지하다"); + } + + public void drift() { + System.out.println("드리프트!!"); + } + + public void open() { + System.out.println("차량커버 열기"); + } + + public void close() { + System.out.println("차량커버 닫기"); + } +} \ No newline at end of file diff --git a/Seminar1/JavaOOPExample/src/Class/Morning.java b/Seminar1/JavaOOPExample/src/Class/Morning.java new file mode 100644 index 0000000..0dccda5 --- /dev/null +++ b/Seminar1/JavaOOPExample/src/Class/Morning.java @@ -0,0 +1,24 @@ +package Class; + +import AbstractClass.Car; + +public class Morning extends Car { + private int price; + + public Morning(String type, double fuelEfficiency, double oilAmount, int price) { + super(type, fuelEfficiency, oilAmount); + this.price = price; + } + + public void go() { + System.out.println("모닝 주행하다"); + } + + public void stop() { + System.out.println("모닝 정지하다"); + } + + public void goBack() { + System.out.println("후진하다"); + } +} diff --git a/Seminar1/JavaOOPExample/src/Interface/Car.java b/Seminar1/JavaOOPExample/src/Interface/Car.java new file mode 100644 index 0000000..900a89e --- /dev/null +++ b/Seminar1/JavaOOPExample/src/Interface/Car.java @@ -0,0 +1,7 @@ +package Interface; + +public interface Car { + void go(); + + void stop(); +} \ No newline at end of file diff --git a/Seminar1/JavaOOPExample/src/Interface/SportsCar.java b/Seminar1/JavaOOPExample/src/Interface/SportsCar.java new file mode 100644 index 0000000..b74b762 --- /dev/null +++ b/Seminar1/JavaOOPExample/src/Interface/SportsCar.java @@ -0,0 +1,5 @@ +package Interface; + +public interface SportsCar extends Car { + void drift(); +} \ No newline at end of file diff --git a/Seminar1/JavaOOPExample/src/Main.java b/Seminar1/JavaOOPExample/src/Main.java new file mode 100644 index 0000000..2010c56 --- /dev/null +++ b/Seminar1/JavaOOPExample/src/Main.java @@ -0,0 +1,30 @@ +import Class.Box; +import Class.Ferrari; +import Class.Morning; +import Class.Avante; +import AbstractClass.Car; + +public class Main { + public static void main(String[] args) { + Avante avante = new Avante("mid size", 15.2, 122.0, 19600000); + Morning morning = new Morning("small size", 12.7, 35.0, 9000000); + go(avante); + go(morning); + Ferrari ferrari = new Ferrari(330); + ferrari.go(); + ferrari.drift(); + Box box = new Box(new String[]{"인형", "태블릿", "노트북"}, 3); + printArray((String[])box.getContents()); + } + + public static void printArray(T[] array) { + for(T element : array) { + System.out.println(element); + } + } + + public static void go(Car car) { + car.go(); + } +} +