├── settings.gradle
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── src
└── main
│ ├── java
│ └── net
│ │ └── harunote
│ │ ├── pattern
│ │ ├── factory
│ │ │ ├── car
│ │ │ │ ├── CarType.java
│ │ │ │ ├── SedanCar.java
│ │ │ │ ├── LuxuryCar.java
│ │ │ │ ├── SmallCar.java
│ │ │ │ ├── TestFactoryPattern.java
│ │ │ │ ├── CarFactory.java
│ │ │ │ └── Car.java
│ │ │ ├── pizzastore
│ │ │ │ ├── NyStyleClamPizza.java
│ │ │ │ ├── NyStyleVeggiePizza.java
│ │ │ │ ├── ChicagoStyleClamPizza.java
│ │ │ │ ├── NyStylePepperoniPizza.java
│ │ │ │ ├── ChicagoStyleVeggiePizza.java
│ │ │ │ ├── ChicagoStylePepperoniPizza.java
│ │ │ │ ├── NyStyleCheesePizza.java
│ │ │ │ ├── PizzaStore.java
│ │ │ │ ├── ChicagoStyleCheesePizza.java
│ │ │ │ ├── ChicagoStylePizza.java
│ │ │ │ ├── PizzaStoreTestDrive.java
│ │ │ │ ├── NyPizzaStore.java
│ │ │ │ ├── ChicagoPizzaStore.java
│ │ │ │ └── Pizza.java
│ │ │ ├── package-info.java
│ │ │ └── legacy
│ │ │ │ ├── Car.java
│ │ │ │ └── CarTest.java
│ │ ├── command
│ │ │ ├── logging
│ │ │ │ ├── Command.java
│ │ │ │ ├── Invoker.java
│ │ │ │ ├── Logger.java
│ │ │ │ ├── LoggerApp.java
│ │ │ │ └── LogCommand.java
│ │ │ ├── Command.java
│ │ │ ├── SellStock.java
│ │ │ ├── BuyStock.java
│ │ │ ├── Stock.java
│ │ │ ├── Broker.java
│ │ │ └── CommandPatternApp.java
│ │ ├── adapter
│ │ │ ├── package-info.java
│ │ │ ├── MediaPlayer.java
│ │ │ ├── AdvancedMediaPlayer.java
│ │ │ ├── Mp4Player.java
│ │ │ ├── VlcPlayer.java
│ │ │ ├── AdapterPatternApp.java
│ │ │ ├── AudioPlayer.java
│ │ │ └── MediaAdapter.java
│ │ ├── strategy
│ │ │ ├── CalculationStrategy.java
│ │ │ ├── AddOperation.java
│ │ │ ├── DivideOperation.java
│ │ │ ├── MultiplyOperation.java
│ │ │ ├── SubstractOperation.java
│ │ │ ├── Calculation.java
│ │ │ ├── Calculator.java
│ │ │ └── CalculationDemo.java
│ │ ├── decorator
│ │ │ ├── CondimentDecorator.java
│ │ │ ├── DarkRoast.java
│ │ │ ├── Beverage.java
│ │ │ ├── Decaf.java
│ │ │ ├── Espresso.java
│ │ │ ├── HouseBlend.java
│ │ │ ├── Soy.java
│ │ │ ├── Mocha.java
│ │ │ ├── Whip.java
│ │ │ └── StarBuzzApps.java
│ │ ├── singleton
│ │ │ ├── package-info.java
│ │ │ ├── Singleton.java
│ │ │ ├── EagerSingleton.java
│ │ │ ├── LazySingleton.java
│ │ │ ├── InitializationOnDemandHolderIdiom.java
│ │ │ └── LazySingletonDoubleCheckLocking.java
│ │ ├── facade
│ │ │ ├── FacedeApp.java
│ │ │ ├── MySqlHelper.java
│ │ │ ├── WithoutFacadeInterfaceApp.java
│ │ │ ├── OracleHelper.java
│ │ │ └── HelperFacade.java
│ │ └── template
│ │ │ ├── application
│ │ │ ├── GlassHouse.java
│ │ │ ├── WoodenHouse.java
│ │ │ └── HouseTemplate.java
│ │ │ └── HousingApp.java
│ │ ├── java8
│ │ ├── functional
│ │ │ ├── consumer
│ │ │ │ ├── PrintLength.java
│ │ │ │ ├── PrintLengthApp.java
│ │ │ │ └── ConsumerExample.java
│ │ │ ├── predicate
│ │ │ │ ├── Tshirt.java
│ │ │ │ ├── TshirtPredicate.java
│ │ │ │ └── TshirtPredicateApp.java
│ │ │ ├── function
│ │ │ │ └── StringLengthExample.java
│ │ │ └── supplier
│ │ │ │ └── RandomNumberSupplier.java
│ │ ├── lambda
│ │ │ ├── runnable
│ │ │ │ ├── RunnableThread.java
│ │ │ │ ├── RunnableInterfaceApp.java
│ │ │ │ └── RunnableLambda.java
│ │ │ └── comparator
│ │ │ │ ├── TshirtSorterLambda.java
│ │ │ │ └── TshirtSorter.java
│ │ └── parameterization
│ │ │ ├── ExecutionExampleApp.java
│ │ │ ├── SortingExampleApp.java
│ │ │ ├── MappingExampleApp.java
│ │ │ ├── EvenNumberPredicate.java
│ │ │ ├── FilteringExampleApp.java
│ │ │ └── CombinationExample.java
│ │ ├── quiz
│ │ ├── input
│ │ │ ├── TextInput.java
│ │ │ ├── NumericInput.java
│ │ │ └── UserInput.java
│ │ ├── ReverseString.java
│ │ ├── ReverseString2.java
│ │ ├── StrToInt.java
│ │ ├── arrays
│ │ │ ├── ArraySort.java
│ │ │ ├── ArrayIndexPosition.java
│ │ │ ├── MultiDimensional.java
│ │ │ └── LeftLotation.java
│ │ ├── practice
│ │ │ ├── EqualString.java
│ │ │ ├── LibraryFine.java
│ │ │ ├── CurrentBuffer.java
│ │ │ ├── CheckBinarySearchTree.java
│ │ │ ├── CompareTheTriplets.java
│ │ │ ├── MakingAnagrams.java
│ │ │ └── HashtableRansomNote.java
│ │ ├── PrintTriangle.java
│ │ ├── EvenOrOdd.java
│ │ ├── BinaryGap.java
│ │ ├── FindKim.java
│ │ ├── WaterMelon.java
│ │ ├── calculation
│ │ │ └── Average.java
│ │ ├── EncodedString.java
│ │ ├── TimeConversion.java
│ │ ├── BirthdayCakeCandle.java
│ │ ├── Palindrom.java
│ │ ├── MinimumMoves.java
│ │ ├── TimeDiffCalculator.java
│ │ ├── PlusMinusGroup.java
│ │ ├── BinaryCadinality.java
│ │ └── Bracket.java
│ │ ├── collection
│ │ ├── sort
│ │ │ ├── actor
│ │ │ │ ├── PrizeYearComparator.java
│ │ │ │ ├── Actor.java
│ │ │ │ └── FilmFestival.java
│ │ │ ├── Product.java
│ │ │ ├── ListSort.java
│ │ │ ├── ArraySort.java
│ │ │ ├── TestMap.java
│ │ │ └── ComplexSort.java
│ │ ├── TreeSetDemo.java
│ │ ├── LinkedHashSetDemo.java
│ │ ├── HashSetDemo.java
│ │ ├── ArrayListToArrayDemo.java
│ │ ├── ArrayListDemo.java
│ │ ├── HashTableDemo.java
│ │ ├── MapDemo.java
│ │ ├── LinkedListDemo.java
│ │ ├── structure
│ │ │ ├── PriorityQueueExample.java
│ │ │ ├── StackExample.java
│ │ │ ├── QueueExample.java
│ │ │ └── DequeExample.java
│ │ ├── HashMapDemo.java
│ │ ├── TreeMapDemo.java
│ │ └── AlgorithmsDemo.java
│ │ └── algorithm
│ │ ├── sort
│ │ ├── ListSort.java
│ │ ├── ArraySort.java
│ │ ├── InsertionSort.java
│ │ ├── BubbleSort.java
│ │ ├── SelectionSort.java
│ │ ├── QuickSort.java
│ │ └── MergeSort.java
│ │ ├── loadbalancer
│ │ ├── RoundRobinLoadBalancer.java
│ │ └── LeastConnectionsLoadBalancer.java
│ │ ├── lru
│ │ └── LRUCache.java
│ │ ├── complexity
│ │ └── ComplexityTest.java
│ │ └── lfu
│ │ └── LFUCache.java
│ └── resources
│ └── log4j.properties
├── .idea
└── vcs.xml
├── .gitignore
├── gradlew.bat
├── README.md
└── gradlew
/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = 'tech-interview'
2 |
3 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/villainscode/tech-interview/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/src/main/java/net/harunote/pattern/factory/car/CarType.java:
--------------------------------------------------------------------------------
1 | package net.harunote.pattern.factory.car;
2 |
3 | public enum CarType {
4 | SMALL, SEDAN, LUXURY
5 | }
6 |
--------------------------------------------------------------------------------
/src/main/java/net/harunote/pattern/command/logging/Command.java:
--------------------------------------------------------------------------------
1 | package net.harunote.pattern.command.logging;
2 |
3 | public interface Command {
4 | void execute();
5 | }
--------------------------------------------------------------------------------
/src/main/java/net/harunote/pattern/adapter/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @Author : CodeVillains
3 | * @Description : 한 클래스의 인터페이스를 클라이언트에서 사용하고자 하는 다른 인터페이스로 변환
4 | */
5 | package net.harunote.pattern.adapter;
--------------------------------------------------------------------------------
/src/main/java/net/harunote/pattern/strategy/CalculationStrategy.java:
--------------------------------------------------------------------------------
1 | package net.harunote.pattern.strategy;
2 |
3 | public interface CalculationStrategy {
4 |
5 | public int calculate(int num1, int num2);
6 | }
--------------------------------------------------------------------------------
/src/main/java/net/harunote/pattern/command/logging/Invoker.java:
--------------------------------------------------------------------------------
1 | package net.harunote.pattern.command.logging;
2 |
3 | public class Invoker {
4 | public void executeCommand(Command command) {
5 | command.execute();
6 | }
7 | }
--------------------------------------------------------------------------------
/src/main/java/net/harunote/pattern/command/Command.java:
--------------------------------------------------------------------------------
1 | package net.harunote.pattern.command;
2 |
3 | /**
4 | * @Author : CodeVillains
5 | * @Description :
6 | */
7 | public interface Command {
8 |
9 | void execute();
10 | }
11 |
--------------------------------------------------------------------------------
/src/main/java/net/harunote/pattern/command/logging/Logger.java:
--------------------------------------------------------------------------------
1 | package net.harunote.pattern.command.logging;
2 |
3 | public class Logger {
4 | public void log(String message) {
5 | System.out.println("Logging: " + message);
6 | }
7 | }
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/src/main/java/net/harunote/pattern/factory/pizzastore/NyStyleClamPizza.java:
--------------------------------------------------------------------------------
1 | package net.harunote.pattern.factory.pizzastore;
2 |
3 | /**
4 | * @Author : CodeVillains
5 | * @Description :
6 | */
7 | public class NyStyleClamPizza extends Pizza {
8 | }
9 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/src/main/java/net/harunote/pattern/factory/pizzastore/NyStyleVeggiePizza.java:
--------------------------------------------------------------------------------
1 | package net.harunote.pattern.factory.pizzastore;
2 |
3 | /**
4 | * @Author : CodeVillains
5 | * @Description :
6 | */
7 | public class NyStyleVeggiePizza extends Pizza {
8 | }
9 |
--------------------------------------------------------------------------------
/src/main/java/net/harunote/pattern/factory/pizzastore/ChicagoStyleClamPizza.java:
--------------------------------------------------------------------------------
1 | package net.harunote.pattern.factory.pizzastore;
2 |
3 | /**
4 | * @Author : CodeVillains
5 | * @Description :
6 | */
7 | public class ChicagoStyleClamPizza extends Pizza {
8 | }
9 |
--------------------------------------------------------------------------------
/src/main/java/net/harunote/pattern/factory/pizzastore/NyStylePepperoniPizza.java:
--------------------------------------------------------------------------------
1 | package net.harunote.pattern.factory.pizzastore;
2 |
3 | /**
4 | * @Author : CodeVillains
5 | * @Description :
6 | */
7 | public class NyStylePepperoniPizza extends Pizza {
8 | }
9 |
--------------------------------------------------------------------------------
/src/main/java/net/harunote/pattern/factory/pizzastore/ChicagoStyleVeggiePizza.java:
--------------------------------------------------------------------------------
1 | package net.harunote.pattern.factory.pizzastore;
2 |
3 | /**
4 | * @Author : CodeVillains
5 | * @Description :
6 | */
7 | public class ChicagoStyleVeggiePizza extends Pizza {
8 | }
9 |
--------------------------------------------------------------------------------
/src/main/java/net/harunote/pattern/factory/pizzastore/ChicagoStylePepperoniPizza.java:
--------------------------------------------------------------------------------
1 | package net.harunote.pattern.factory.pizzastore;
2 |
3 | /**
4 | * @Author : CodeVillains
5 | * @Description :
6 | */
7 | public class ChicagoStylePepperoniPizza extends Pizza {
8 | }
9 |
--------------------------------------------------------------------------------
/src/main/java/net/harunote/pattern/adapter/MediaPlayer.java:
--------------------------------------------------------------------------------
1 | package net.harunote.pattern.adapter;
2 |
3 | /**
4 | * @Author : CodeVillains
5 | * @Description :
6 | */
7 | public interface MediaPlayer {
8 | public void play(String audioType, String fileName);
9 | }
10 |
--------------------------------------------------------------------------------
/src/main/java/net/harunote/pattern/decorator/CondimentDecorator.java:
--------------------------------------------------------------------------------
1 | package net.harunote.pattern.decorator;
2 |
3 | /**
4 | * @Author : CodeVillains
5 | * @Description :
6 | */
7 | public abstract class CondimentDecorator extends Beverage {
8 | public abstract String getDescription();
9 | }
10 |
--------------------------------------------------------------------------------
/src/main/java/net/harunote/pattern/singleton/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @Author : CodeVillains
3 | * @Description : 인스턴스를 계속만들어 내는 것이 아닌, 동일 인스턴스를 사용하게 해야할 경우 사용된다.
4 | * 공용으로 사용하는 클래스(환경 설정 클래스나 커넥션 풀 등)와 같이 프로그램의 종료 시점까지 단 하나의 인스턴스만을 생성하고 재 사용한다거나 관리할 때 유용하다.
5 | */
6 | package net.harunote.pattern.singleton;
--------------------------------------------------------------------------------
/src/main/java/net/harunote/java8/functional/consumer/PrintLength.java:
--------------------------------------------------------------------------------
1 | package net.harunote.java8.functional.consumer;
2 |
3 | import java.util.function.Consumer;
4 |
5 | class PrintLength implements Consumer {
6 | public void accept(String color) {
7 | System.out.println(color.length());
8 | }
9 | }
--------------------------------------------------------------------------------
/src/main/java/net/harunote/quiz/input/TextInput.java:
--------------------------------------------------------------------------------
1 | package net.harunote.quiz.input;
2 |
3 | class TextInput {
4 | static String textInput = "";
5 | public void add(char c) {
6 | textInput += c;
7 | }
8 |
9 | public String getValue() {
10 | return textInput;
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/src/main/resources/log4j.properties:
--------------------------------------------------------------------------------
1 | log4j.properties=
2 | log4j.rootLogger=INFO, stdout
3 |
4 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender
5 | log4j.appender.stdout.Target=System.out
6 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
7 | log4j.appender.stdout.layout.ConversionPattern= %-5p %c{1}:%L - %m%n
--------------------------------------------------------------------------------
/src/main/java/net/harunote/java8/lambda/runnable/RunnableThread.java:
--------------------------------------------------------------------------------
1 | package net.harunote.java8.lambda.runnable;
2 |
3 | public class RunnableThread implements Runnable {
4 | @Override
5 | public void run() {
6 | System.out.println("Runnable 구현 " + Thread.currentThread().getName());
7 | }
8 | }
9 |
10 |
--------------------------------------------------------------------------------
/src/main/java/net/harunote/pattern/adapter/AdvancedMediaPlayer.java:
--------------------------------------------------------------------------------
1 | package net.harunote.pattern.adapter;
2 |
3 | /**
4 | * @Author : CodeVillains
5 | * @Description :
6 | */
7 | public interface AdvancedMediaPlayer {
8 | public void playVlc(String fileName);
9 |
10 | public void playMp4(String fileName);
11 | }
12 |
--------------------------------------------------------------------------------
/src/main/java/net/harunote/pattern/decorator/DarkRoast.java:
--------------------------------------------------------------------------------
1 | package net.harunote.pattern.decorator;
2 |
3 | public class DarkRoast extends Beverage {
4 |
5 | public DarkRoast() {
6 | description = "다크로스트";
7 | }
8 |
9 | @Override
10 | public double cost() {
11 | return 2.8;
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/main/java/net/harunote/pattern/strategy/AddOperation.java:
--------------------------------------------------------------------------------
1 | package net.harunote.pattern.strategy;
2 |
3 | /**
4 | * @author CodeVillains
5 | */
6 | public class AddOperation implements CalculationStrategy{
7 | @Override
8 | public int calculate(int num1, int num2) {
9 | return num1 + num2;
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/main/java/net/harunote/pattern/strategy/DivideOperation.java:
--------------------------------------------------------------------------------
1 | package net.harunote.pattern.strategy;
2 |
3 | /**
4 | * @author CodeVillains
5 | */
6 | public class DivideOperation implements CalculationStrategy{
7 | @Override
8 | public int calculate(int num1, int num2) {
9 | return num1 / num2;
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/main/java/net/harunote/pattern/strategy/MultiplyOperation.java:
--------------------------------------------------------------------------------
1 | package net.harunote.pattern.strategy;
2 |
3 | /**
4 | * @author CodeVillains
5 | */
6 | public class MultiplyOperation implements CalculationStrategy{
7 | @Override
8 | public int calculate(int num1, int num2) {
9 | return num1 * num2;
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/main/java/net/harunote/pattern/strategy/SubstractOperation.java:
--------------------------------------------------------------------------------
1 | package net.harunote.pattern.strategy;
2 |
3 | /**
4 | * @author CodeVillains
5 | */
6 | public class SubstractOperation implements CalculationStrategy{
7 | @Override
8 | public int calculate(int num1, int num2) {
9 | return num1 - num2;
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/main/java/net/harunote/pattern/decorator/Beverage.java:
--------------------------------------------------------------------------------
1 | package net.harunote.pattern.decorator;
2 |
3 | /**
4 | * @Author : CodeVillains
5 | * @Description :
6 | */
7 | public abstract class Beverage {
8 | String description = "제목없음";
9 |
10 | public String getDescription() {
11 | return description;
12 | }
13 |
14 | public abstract double cost();
15 | }
16 |
--------------------------------------------------------------------------------
/src/main/java/net/harunote/pattern/decorator/Decaf.java:
--------------------------------------------------------------------------------
1 | package net.harunote.pattern.decorator;
2 |
3 | /**
4 | * @Author : CodeVillains
5 | * @Description :
6 | */
7 | public class Decaf extends Beverage {
8 |
9 | public Decaf() {
10 | description = "디카프";
11 | }
12 |
13 | @Override
14 | public double cost() {
15 | return 1.2;
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/java/net/harunote/pattern/factory/car/SedanCar.java:
--------------------------------------------------------------------------------
1 | package net.harunote.pattern.factory.car;
2 |
3 | public class SedanCar extends Car {
4 | SedanCar() {
5 | super(CarType.SEDAN);
6 | construct();
7 | }
8 | @Override
9 | protected void construct() {
10 | System.out.println("Building sedan car");
11 | // do something
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/main/java/net/harunote/pattern/decorator/Espresso.java:
--------------------------------------------------------------------------------
1 | package net.harunote.pattern.decorator;
2 |
3 | /**
4 | * @Author : CodeVillains
5 | * @Description :
6 | */
7 | public class Espresso extends Beverage {
8 | public Espresso() {
9 | description = "에스프레소";
10 | }
11 |
12 | @Override
13 | public double cost() {
14 | return 1.99;
15 | }
16 |
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/src/main/java/net/harunote/pattern/decorator/HouseBlend.java:
--------------------------------------------------------------------------------
1 | package net.harunote.pattern.decorator;
2 |
3 | /**
4 | * @Author : CodeVillains
5 | * @Description :
6 | */
7 | public class HouseBlend extends Beverage {
8 | public HouseBlend() {
9 | description = "하우스 브렌드 커피";
10 | }
11 |
12 | @Override
13 | public double cost() {
14 | return .89;
15 | }
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/java/net/harunote/pattern/factory/car/LuxuryCar.java:
--------------------------------------------------------------------------------
1 | package net.harunote.pattern.factory.car;
2 |
3 | public class LuxuryCar extends Car {
4 | LuxuryCar() {
5 | super(CarType.LUXURY);
6 | construct();
7 | }
8 |
9 | @Override
10 | protected void construct() {
11 | System.out.println("Building luxury Car");
12 | // do something
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/net/harunote/pattern/factory/car/SmallCar.java:
--------------------------------------------------------------------------------
1 | package net.harunote.pattern.factory.car;
2 |
3 |
4 | public class SmallCar extends Car {
5 | SmallCar() {
6 | super(CarType.SMALL);
7 | construct();
8 | }
9 |
10 | @Override
11 | protected void construct() {
12 | System.out.println("Building small car");
13 | // do something
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/main/java/net/harunote/pattern/singleton/Singleton.java:
--------------------------------------------------------------------------------
1 | package net.harunote.pattern.singleton;
2 |
3 | public class Singleton {
4 | private Singleton() {
5 | }
6 |
7 | private static class SingletonHolder {
8 | private static final Singleton INSTANCE = new Singleton();
9 | }
10 |
11 | public static Singleton getInstance() {
12 | return SingletonHolder.INSTANCE;
13 | }
14 | }
--------------------------------------------------------------------------------
/src/main/java/net/harunote/quiz/ReverseString.java:
--------------------------------------------------------------------------------
1 | package net.harunote.quiz;
2 |
3 | public class ReverseString {
4 | public static void main(String[] args) {
5 | ReverseString rs = new ReverseString();
6 | System.out.println(rs.reverseStr("ABCDefg"));
7 | }
8 |
9 | private String reverseStr(String str) {
10 | return new StringBuilder(str).reverse().toString();
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/src/main/java/net/harunote/pattern/factory/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @Author : CodeVillains
3 | * @Description : 팩토리 패턴
4 | * - Object 생성시 new 를 사용하여 생성할 경우 Concrete class 를 의존하여 코딩하기 때문에 결합도가 매우 높다. (수정시 의존도가 높고 유연성이 떨어짐)
5 | * - Factorty Pattern을 통해 실제 사용하는 곳에서 Concrete class를 정하지 않고 Factory 를 사용하여 의존성을 받도록 하여 Concrete class를
6 | * 전혀 의존하지 않도록 한다 (DIP : Depencency Inversion Priciple)
7 | */
8 | package net.harunote.pattern.factory;
--------------------------------------------------------------------------------
/src/main/java/net/harunote/pattern/command/SellStock.java:
--------------------------------------------------------------------------------
1 | package net.harunote.pattern.command;
2 |
3 | /**
4 | * @Author : CodeVillains
5 | * @Description :
6 | */
7 | public class SellStock implements Command {
8 | private Stock stock;
9 |
10 | public SellStock(Stock stock) {
11 | this.stock = stock;
12 | }
13 |
14 | @Override
15 | public void execute() {
16 | stock.sell();
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/main/java/net/harunote/pattern/command/BuyStock.java:
--------------------------------------------------------------------------------
1 | package net.harunote.pattern.command;
2 |
3 | /**
4 | * @Author : CodeVillains
5 | * @Description :
6 | */
7 | public class BuyStock implements Command {
8 |
9 | private Stock stock;
10 |
11 | public BuyStock(Stock stock) {
12 | this.stock = stock;
13 | }
14 |
15 | @Override
16 | public void execute() {
17 | stock.buy();
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/java/net/harunote/quiz/input/NumericInput.java:
--------------------------------------------------------------------------------
1 | package net.harunote.quiz.input;
2 |
3 | class NumericInput extends TextInput {
4 | static String numberInput = "";
5 |
6 | @Override
7 | public void add(char c) {
8 | if (Character.isDigit(c)){
9 | numberInput += c;
10 | }
11 | }
12 |
13 | @Override
14 | public String getValue() {
15 | return numberInput;
16 | }
17 | }
18 |
19 |
--------------------------------------------------------------------------------
/src/main/java/net/harunote/pattern/command/logging/LoggerApp.java:
--------------------------------------------------------------------------------
1 | package net.harunote.pattern.command.logging;
2 |
3 | /**
4 | * @author CodeVillains
5 | */
6 | public class LoggerApp {
7 | public static void main(String[] args) {
8 | Logger logger = new Logger();
9 | Command logCommand = new LogCommand(logger, "Hello, World!");
10 | Invoker invoker = new Invoker();
11 | invoker.executeCommand(logCommand);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/main/java/net/harunote/quiz/ReverseString2.java:
--------------------------------------------------------------------------------
1 | package net.harunote.quiz;
2 |
3 | /**
4 | * @author CodeVillains
5 | */
6 | public class ReverseString2 {
7 | public static void main(String[] args) {
8 | String str = "ABCDefg";
9 | // 문자 배열로 변환한 뒤 역순으로 출력한다.
10 | char chars[] = str.toCharArray();
11 | for(int i= chars.length-1; i >= 0; i--) {
12 | System.out.print(chars[i]);
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/main/java/net/harunote/quiz/input/UserInput.java:
--------------------------------------------------------------------------------
1 | package net.harunote.quiz.input;
2 |
3 | /**
4 | * @Author : CodeVillains
5 | * @Description :
6 | */
7 | public class UserInput {
8 | public static void main(String[] args) {
9 | TextInput input = new NumericInput();
10 | input.add('a');
11 | input.add('b');
12 | input.add('z');
13 | input.add('z');
14 | System.out.println(input.getValue());
15 | }
16 | }
--------------------------------------------------------------------------------
/src/main/java/net/harunote/pattern/adapter/Mp4Player.java:
--------------------------------------------------------------------------------
1 | package net.harunote.pattern.adapter;
2 |
3 | /**
4 | * @Author : CodeVillains
5 | * @Description :
6 | */
7 | public class Mp4Player implements AdvancedMediaPlayer {
8 | @Override
9 | public void playVlc(String fileName) {
10 |
11 | }
12 |
13 | @Override
14 | public void playMp4(String fileName) {
15 | System.out.println("Playing mp4 file. name : " + fileName);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/java/net/harunote/pattern/strategy/Calculation.java:
--------------------------------------------------------------------------------
1 | package net.harunote.pattern.strategy;
2 |
3 | /**
4 | * @author CodeVillains
5 | */
6 | public class Calculation {
7 | private CalculationStrategy strategy;
8 |
9 | public Calculation(CalculationStrategy strategy) {
10 | this.strategy = strategy;
11 | }
12 |
13 | public int executeStrategy(int num1, int num2) {
14 | return strategy.calculate(num1, num2);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/main/java/net/harunote/pattern/command/logging/LogCommand.java:
--------------------------------------------------------------------------------
1 | package net.harunote.pattern.command.logging;
2 |
3 | public class LogCommand implements Command {
4 | private Logger logger;
5 | private String message;
6 |
7 | public LogCommand(Logger logger, String message) {
8 | this.logger = logger;
9 | this.message = message;
10 | }
11 |
12 | @Override
13 | public void execute() {
14 | logger.log(message);
15 | }
16 | }
--------------------------------------------------------------------------------
/src/main/java/net/harunote/java8/functional/predicate/Tshirt.java:
--------------------------------------------------------------------------------
1 | package net.harunote.java8.functional.predicate;
2 |
3 |
4 | import lombok.Getter;
5 | import lombok.ToString;
6 |
7 | /**
8 | * @author CodeVillains
9 | */
10 | @Getter
11 | @ToString
12 | public class Tshirt {
13 | private int price;
14 | private String color;
15 |
16 | public Tshirt(int price, String color) {
17 | this.price = price;
18 | this.color = color;
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/src/main/java/net/harunote/pattern/adapter/VlcPlayer.java:
--------------------------------------------------------------------------------
1 | package net.harunote.pattern.adapter;
2 |
3 | /**
4 | * @Author : CodeVillains
5 | * @Description :
6 | */
7 | public class VlcPlayer implements AdvancedMediaPlayer {
8 | @Override
9 | public void playVlc(String fileName) {
10 | System.out.println("Playing VLC File. name = " + fileName);
11 |
12 | }
13 |
14 | @Override
15 | public void playMp4(String fileName) {
16 |
17 |
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/java/net/harunote/collection/sort/actor/PrizeYearComparator.java:
--------------------------------------------------------------------------------
1 | package net.harunote.collection.sort.actor;
2 |
3 | import java.util.Comparator;
4 |
5 | // 수상 연도별로 정렬하기 위해 Comparator 인터페이스를 구현
6 | class PrizeYearComparator implements Comparator