인프런 워밍업 스터디/과제

인프런 워밍업 스터디/과제

[인프런 워밍업 스터디 클럽 0기 - BE] #7 과제

문제1 Fruit @Entity public class Fruit { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id = null; @Column(nullable = false, length = 20) private String name; @Column(nullable = false) private Long price; @Column(nullable = false, name = "stocked_date") private LocalDate warehousingDate; @Column(nullable = false) private int sold = 0; public Fruit() { } public Fruit(String na..

인프런 워밍업 스터디/과제

[인프런 워밍업 스터디 클럽 0기 - BE] #6 과제

문제 Controller @RestController public class FruitController { private final FruitService fruitService; public FruitController(FruitService fruitService) { this.fruitService = fruitService; } @PostMapping("/api/v1/fruit") public void saveFruit(@RequestBody FruitRequest request) { fruitService.saveFruit(request); } @PutMapping("/api/v1/fruit") public void saleFruit(@RequestBody SoldOutFruitRequest ..

인프런 워밍업 스터디/과제

[인프런 워밍업 스터디 클럽 0기 - BE] #5 과제

문제1 import java.util.Scanner; public class Main { public static void main(String[] args) { int inputDice = inputPrint(); int[] dice = rollDice(inputDice); OutPutPrint(dice); } private static int inputPrint() { Scanner scanner = new Scanner(System.in); System.out.print("숫자를 입력하세요 : "); return scanner.nextInt(); } private static int[] rollDice(int inputDice) { int[] dice = new int[inputDice]; for ..

인프런 워밍업 스터디/과제

[인프런 워밍업 스터디 클럽 0기 - BE] #4 과제

문제 1 Domain public class Fruit { private String name; private Long price; private LocalDate localDate; public Fruit(String name, Long price, LocalDate localDate) { this.name = name; this.price = price; this.localDate = localDate; } public String getName() { return name; } public Long getPrice() { return price; } public LocalDate getLocalDate() { return localDate; } } DTO public class FruitCreate..

인프런 워밍업 스터디/과제

[인프런 워밍업 스터디 클럽 0기 - BE] #3 과제

익명 클래스 익명 클래스란 이름이 없다는 뜻 다시말해 나중에다시 한번 불러질 이유가없다는뜻이다. 프로그래밍적으로 말한다면 프로그램에서 한번만 사용되고 버려진다는것이다. 나중에 나중에 재사용하지않는것이다. 정리하자면 1. 재사용성이 없을때 2. 단발성으로(한번) 만 사용되어야하는 객체일경우 특징 1. 클래스 정의와 동시에 객체 생성 가능 2. 부모 클래스의 자원을 상속받아 재정의하여 사용할 계획이라면 지역 변수처럼 익명 클래스를 정의하는 것이 좋음 3. 오버라이딩 한 메소드만 사용 가능하고 새로 정의한 메소드는 외부에서 사용이 불가능함 4. 새로 정의한 메소드는 익명 클래스 내에서만 호출 가능 5.이름이 없기 때문에 생성자를 가질 수 없고 가질 필요도 없음 예시 public class Person { St..

인프런 워밍업 스터디/과제

[인프런 워밍업 스터디 클럽 0기 - BE] #2 과제

문제 1 Controller @GetMapping("api/v1/calc") public Calc calc(CalcResponse request){ return new Calc(request); } Domain public class Calc { private int add; private int minus; private int multiply; public Calc(CalcResponse response) { this.add = response.getNum1() + response.getNum2(); this.minus = response.getNum1() - response.getNum2(); this.multiply = response.getNum1() * response.getNum2(); } ..

인프런 워밍업 스터디/과제

[인프런 워밍업 스터디 클럽 0기 - BE] #1 과제

질문 1. 어노테이션을 사용하는 이유 (효과)는 무엇일까? 2. 나만의 어노테이션은 어떻게 만들 수 있을까? 1. 어노테이션을 사용하는 이유 (효과) 는 무엇일까? Annotation 이란? 어노테이션은 메타 데이터로서, 프로그램 그 자체의 일부분은 아니지만 프로그램에 대한 데이터를 제공한다. 그래서 어노테이션 자체는 어노테이션을 붙은 코드 동작에 영향을 미치지는 않는다. 대부분이 많이 봤을 만한 @Override, @Deprecated 가 Annotation 예로 Annotation의 구현된 정보에 따라 연결되는 방향이 결정됩니다. 참고로 어노테이션은 다음과 같은 상황에 사용된다. 컴파일러에게 필요한 정보를 제공 컴파일러가 에러를 감지하거나, 경고를 띄우지 않게 하기 위함. 컴파일/배포 시에 필요한 처..

2_no
'인프런 워밍업 스터디/과제' 카테고리의 글 목록