View
77
Download
1
Category
Preview:
Citation preview
[Live Coding] 2주차_5/23
method란?methodwhileswitch-case
복습
객체가수행할 수 있는일련의
동작들의 묶음
http://camp-android.slack.com
[Live Coding] 2주차_5/23
method란?methodwhileswitch-case
복습
객체가수행할 수 있는일련의
동작들의 묶음by Wikipedia
(http://en.wikipedia.org/wiki/Method_(computer_programming))
http://camp-android.slack.com
[Live Coding] 2주차_5/23
method란?method(1/3)
whileswitch-case
복습
public class MainActivity extends Activity {
private TextView resultView;private static final int FOR_COUNT = 50;
@Overrideprotected void onCreate(Bundle savedInstanceState) { // method 이름
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
resultView = (TextView) findViewById(R.id.result);}...
http://camp-android.slack.com
[Live Coding] 2주차_5/23
method란?method(1/3)
whileswitch-case
복습
public class MainActivity extends Activity {
private TextView resultView;private static final int FOR_COUNT = 50;
@Override // method 의protected void onCreate(Bundle savedInstanceState) { // 인자 type 과
super.onCreate(savedInstanceState); // 인자 name
setContentView(R.layout.activity_main);
resultView = (TextView) findViewById(R.id.result);}...
Bundle 이란? (http://developer.android.com/intl/ko/reference/android/os/Bundle.html)
http://camp-android.slack.com
[Live Coding] 2주차_5/23
method란?method(1/3)
whileswitch-case
복습
public class MainActivity extends Activity {
private TextView resultView;private static final int FOR_COUNT = 50;
@Override // method 의protected void onCreate(Bundle savedInstanceState) { // 인자 type 과
super.onCreate(savedInstanceState); // 인자 name
setContentView(R.layout.activity_main);
resultView = (TextView) findViewById(R.id.result);}...
Bundle 이란? (http://developer.android.com/intl/ko/reference/android/os/Bundle.html)
http://camp-android.slack.com
type을 아파트에 비유하면...
- 몇 평짜리 아파트인가?- 몇 층짜리 아파트인가?- 계단식인가?- 지하주차장이 충분한가?- 어떤 브랜드의 아파트인가?
[Live Coding] 2주차_5/23
method란?method(1/3)
whileswitch-case
복습
public class MainActivity extends Activity {
private TextView resultView;private static final int FOR_COUNT = 50;
@Override // method 의protected void onCreate(Bundle savedInstanceState) { // 인자 type 과
super.onCreate(savedInstanceState); // 인자 name
setContentView(R.layout.activity_main);
resultView = (TextView) findViewById(R.id.result);}...
Bundle 이란? (http://developer.android.com/intl/ko/reference/android/os/Bundle.html)
http://camp-android.slack.com
아파트는 메모리(램 혹은 힙)에 존재함.
- Bundle type 의 캠프아파트가 신사동 어딘가에 존재- Bundle type 의 객체가 메모리(램 혹은 힙) 어딘가에 존재
[Live Coding] 2주차_5/23
method란?method(2/3)
whileswitch-case
복습
@Overrideprotected void onResume() {
super.onResume();...
result = result + getForResultBinary();...}
private String getForResultBinary() {...}
http://camp-android.slack.com
[Live Coding] 2주차_5/23
method란?method(2/3)
whileswitch-case
복습
@Overrideprotected void onResume() {
super.onResume();...
result = result + getForResultBinary(); // method 호출...}
private String getForResultBinary() { // method 선언 및 정의...// 어떤 동작들이 있어야 하는지 정의...}
http://camp-android.slack.com
[Live Coding] 2주차_5/23
method란?method(3/3)
whileswitch-case
복습
@Overrideprotected void onResume() {
super.onResume();
String result = getIfResult(5, 10);...}
private String getIfResult(int a, int b) {String retVal = null;
if (a > b) {retVal = String.format("a = %d\nb = %d\n\na > b", a, b);
} else if (a < b) {...
http://camp-android.slack.com
[Live Coding] 2주차_5/23
method란?method(3/3)
whileswitch-case
복습
http://camp-android.slack.com
@Overrideprotected void onResume() {
super.onResume();
String result = getIfResult(5, 10); // 정수형 인자 2개 전달...}
private String getIfResult(int a, int b) { // 인자 2개를 a 와 b 로 받음String retVal = null;
if (a > b) {retVal = String.format("a = %d\nb = %d\n\na > b", a, b);
} else if (a < b) {...
[Live Coding] 2주차_5/23
method란?methodwhileswitch-case
복습
int i = 0;while (i < LIMIT) {
++i;...
}
http://camp-android.slack.com
[Live Coding] 2주차_5/23
method란?methodwhileswitch-case
복습
int i = 0;while (i < LIMIT) {
++i;...
}// while 은 for로 바꿔 쓸 수 있음.
for (int i = 0; i < LIMIT; ++i) {...
}
http://camp-android.slack.com
[Live Coding] 2주차_5/23
method란?methodwhileswitch-case
복습
출처: http://day30.tistory.com/5
http://camp-android.slack.com
[Live Coding] 2주차_5/23
method란?methodwhileswitch-case(1/3)
복습
switch (expression) {case condition1:
...break;
case condition2:...break;
default:...break;
}
http://camp-android.slack.com
[Live Coding] 2주차_5/23
method란?methodwhileswitch-case(2/3)
복습
switch (배고픈정도) {case “많이배고픔”:
... // 배달의요기요break;
case “참을만함”:... // 요기요민족break;
default:... // 라면물끓이기break;
}
http://camp-android.slack.com
[Live Coding] 2주차_5/23
whileswitch-case
method란?method
코딩
컴퓨터와 즐거운 대화를~
http://camp-android.slack.com
Recommended