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
39 changes: 37 additions & 2 deletions src/daeyoung/src/Main.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,46 @@
import base.Car;
import base.Case1;

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

// Press Shift twice to open the Search Everywhere dialog and type `show whitespaces`,
// then press Enter. You can now see whitespace characters in your code.
public class Main {
public static void main(String[] args) {
Case1 main = new Case1();
main.gameStart(6);
// Case1 case1 = new Case1();
// case1.gameStart(3);


List<Car> carList = new ArrayList<>();
Car bluecar = new Car("파란 차");
// 여기서 new Car 는 Car 클래스의 12번째줄의 생성자 Car를 따른다
Car blackcar = new Car("검정색 차", "제네시스", 258, "가솔린");
// 여기서 new Car 는 Car 클래스의 20번째줄의 생성자 Car를 따른다

// for (Integer i = 0 ; i < 10 ; i ++) { // 범위형태로 list 만들수 있음, 이러면 더미 데이터로 들어감
// carList.add(new Car("아무거나"));
// }

carList.add(bluecar); // carList 안에 bluecar를 넣어주는것, List안에 일일히 적어서 넣어주어야 한다.
carList.add(blackcar);

// for(Car car : carList) {
// System.out.println(car.무슨색차니()); //
// System.out.println(car.무슨브랜드와무슨색을가지고있니());
// }


for(Integer i = 0 ; i < 10 ; i++) {
bluecar.가속하기();
}



for(Car car : carList) {
System.out.println(car.무슨색차니() + " 현재 차의 속력은 " + car.현재속력은());
}



}
Expand Down
49 changes: 49 additions & 0 deletions src/daeyoung/src/base/Car.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package base;

public class Car {
// 밑에 내용들은 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 = 250;
this.fuel = "전기";
this.currentSpeed = 0;
}

public Car(String inputcolor, String inputBrand, Integer inputmaxSpeed, String inputfuel) {
this.color = inputcolor;
this.brand = inputBrand;
this.maxSpeed = inputmaxSpeed;
this.fuel = inputfuel;
this.currentSpeed = 0;
}

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

public String 무슨브랜드와무슨색을가지고있니(){
return "브랜드는 " + this.brand + " 색은 " + this.color;
}

public void 가속하기 () {
this.currentSpeed += 1;
}

public void 감속하기 () {
this.currentSpeed -= 1;
}

public Integer 현재속력은() {
return this.currentSpeed;
}


}
55 changes: 55 additions & 0 deletions src/daeyoung/src/base/House.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package base;

public class House {

static Integer Window = 5;
private String Brand;
private String Kind;
private Integer Area;
private Integer Floor;
private Integer Elevator;

public House(String inputBrand, String inputKind, Integer inputArea, Integer inputFloor) {
this.Brand = inputBrand;
this.Kind = inputKind;
this.Area = inputArea;
this.Floor = inputFloor;
this.Elevator = 0;
}

public House(Integer inputArea) {
this.Brand = "삼성";
this.Kind = "아파트";
this.Area = inputArea;
this.Floor = 5;
this.Elevator = 0;
}

public String 건물_브랜드가무엇이니() {
return this.Brand;
}

public Integer 집면적이_얼마나되니() {
return this.Area;
}

public Integer 이건물의_층수는() {
return this.Floor;
}

public Integer 엘레베이터_현재위치는() {
return this.Elevator;
}

public void 엘레베이터_올라가기() {
this.Elevator += 1;
}

public void 엘레베이터_내려가기() {
this.Elevator -= 1;
}




}