Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions src/src/SeulBi/Car.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package SeulBi;

public class Car {

static Integer WHEEL_COUNT = 4;
private String color;
private String brand;
private Integer maxSpeed;
private Integer currentSpeed;
private String fuel;

public Car(String inputColor){
this.color = inputColor;
this.brand = "테슬라";
this.maxSpeed = 1;
this.fuel = "전기";
currentSpeed = 0;
}

public Car(String inputColor, String inputBrand, Integer maxSpeed, String fuel){
this.color = inputColor;
this.brand = inputBrand;
this.maxSpeed = maxSpeed;
this.fuel = fuel;
currentSpeed = 0; // 생성 시 굳이 필요 없는 것은 초기화하여도 됨
}

public String 무슨색차니(){
return this.color;
}

public String 무슨브랜드와무슨색을가지고있니(){
System.out.println("브랜드는 " + this.brand);
System.out.println("색은 " + this.color +"입니다.");

return this.color;
}

public Integer 가속하기(Integer plusSpeed){
this.currentSpeed += plusSpeed;
return currentSpeed;
}

public Integer 감속하기(Integer minusSpeed){
if(this.currentSpeed <= 0){
System.out.println("이미 속도가 0입니다.");
} else { this.currentSpeed -= minusSpeed;}

return currentSpeed;
}
}
100 changes: 100 additions & 0 deletions src/src/SeulBi/SunCream.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
package SeulBi;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

public class SunCream {
private String brand; // 회사 이름
private String productName; // 상품 이름
private Integer sunProtectionFactor = 50; // 자외선 차단 지수
private String formulation; // 제형
private Double millilitre; // 용량
private Double remainingMillilitre; // 남은 양
private final Integer effectTimeOfSPA = sunProtectionFactor*15; // 자외선 차단 지속 시간(분)
private Integer price; // 가격
private static final Double recommendMl = 0.8;

private List<SunCream> basket = new ArrayList<>();

SunCream(String brand, String productName){
this.brand = brand;
this.productName = productName;
this.formulation = "무기자차";
this.millilitre = 50.0;
this.remainingMillilitre = this.millilitre;
this.price = 8000;
}

SunCream(String brand, String productName, String formulation, Integer spf, Double millilitre, Integer price){
this.brand = brand;
this.productName = productName;
this.formulation = formulation;
this.sunProtectionFactor = spf;
this.millilitre = millilitre;
this.remainingMillilitre = this.millilitre;
this.price = price;
}

public void buySunCream(){
System.out.println("구매가 완료되었습니다.");
System.out.println();
System.out.println(brand + " 회사의 [" + productName +"] 상품을 선택하셨습니다.");
System.out.println("제형은 " + formulation + "이며 자외선 차단 지수는 " + sunProtectionFactor+"입니다.");
System.out.println("용량은 " + millilitre +"ml이고, 가격은 " + price + "원입니다." );
System.out.println("----------------------------------------------------------");

basket.add(new SunCream(brand, productName, formulation, sunProtectionFactor, millilitre, price));
}

public Double useSuncream(Double usingMillilitre){
if(Objects.equals(remainingMillilitre,0.0)){
System.out.println("남은 선크림이 없습니다. 새로운 선크림을 구입해 보세요!");
System.out.println("----------------------------------------------------------");
} else if (millilitre - usingMillilitre < 0.0){
System.out.println("남은 용량보다 많은 양을 사용하실 수 없습니다.");
System.out.println("----------------------------------------------------------");
} else if(millilitre - usingMillilitre >= 0.0) {
remainingMillilitre = millilitre - usingMillilitre;
if(usingMillilitre < recommendMl){
System.out.println("선크림을 " + usingMillilitre + "ml 사용하셨습니다.");
System.out.println("성인의 선크림 권장 용량은 1회당 최소 " + recommendMl + "ml이므로 자외선 차단 시간 측정이 어렵습니다.");
System.out.println("다음 번에는 권장 용량을 지켜 사용하시는 것을 추천드립니다.");
System.out.println("남은 선크림 용량은 "+ remainingMillilitre+"ml입니다.");
System.out.println("즐거운 외출 되세요!");
System.out.println("----------------------------------------------------------");
} else {
System.out.println("선크림을 " + usingMillilitre + "ml 사용하셨습니다.");
System.out.println("자외선 차단 지속 시간은 " + effectTimeOfSPA + "분이며 남은 선크림 용량은 "+ remainingMillilitre+"ml입니다.");
System.out.println("즐거운 외출 되세요!");
System.out.println("----------------------------------------------------------");
}
}

return remainingMillilitre;
}

public void checkSuncream(){
System.out.println(productName + "의 자외선 차단 지수는 " + sunProtectionFactor + "이며 남은 용량은 " + remainingMillilitre + "ml입니다." );
System.out.println("----------------------------------------------------------");
}

public static void main(String[] args) {
// 메서드 확인용 객체 생성
SunCream mySunCream1 = new SunCream("에뛰드","순정 선크림");
SunCream mySunCream2 = new SunCream("라운드랩","자작나무 수분 선크림","무기자차",50,50.0,12000);

mySunCream1.buySunCream();
mySunCream2.buySunCream();

mySunCream1.useSuncream(0.5);
mySunCream2.useSuncream(50.0);

mySunCream1.useSuncream(0.8);
mySunCream2.useSuncream(1.0);

mySunCream1.checkSuncream();


}
}