Last active
April 17, 2016 07:46
-
-
Save happydeveloper/bb02b14e5b341987c1531da238b2c580 to your computer and use it in GitHub Desktop.
자바 클래스 구현
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package kr.duru.code; | |
/** | |
* Created by duru on 2016. 4. 17.. | |
*/ | |
public class Car { | |
public Car() { | |
} | |
int speed; | |
int distance; | |
String color; | |
public void speedUp() | |
{ | |
System.out.println("Speed Up +5"); | |
speed = speed + 5; | |
} | |
public void breakDown() | |
{ | |
System.out.println("Break down -10"); | |
speed = speed - 10; | |
} | |
public int getCurruntSpeed() | |
{ | |
System.out.println("current speed"); | |
return speed; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package kr.duru.code; | |
public class Main { | |
public static void main(String[] args) { | |
// write your code here | |
Car dogCar = new Car(); | |
dogCar.speedUp(); | |
dogCar.speedUp(); | |
Car cowCar = new Car(); | |
cowCar.breakDown(); | |
//http://stackoverflow.com/questions/5071040/java-convert-integer-to-string | |
/** | |
* 자바에서 형변환 | |
*/ | |
System.out.println("현재 속도 dogCar : " + Integer.toString(dogCar.getCurruntSpeed())); | |
System.out.println("현재 속도 cowCar : " + Integer.toString(cowCar.getCurruntSpeed())); | |
System.out.println("현재 속도 " + String.valueOf(cowCar.getCurruntSpeed())); | |
System.out.println("Current Speed dogCar : " + dogCar.getCurruntSpeed()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment