-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from KEEPER31337/problem5-yejun
problem5-yejun
- Loading branch information
Showing
15 changed files
with
90 additions
and
104 deletions.
There are no files selected for viewing
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,20 @@ | ||
package Problem.yejun.Chapter5; | ||
|
||
public class Q04 { | ||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
|
||
/** | ||
* 평균값을 구하는 메서드 | ||
*/ | ||
public static void main(String[] args) { | ||
public class Q04 { | ||
|
||
// TODO: 다음과 같이 정수 배열 또는 정수의 리스트로 그 평균값을 구해 리턴하는 Calculator 클래스를 작성하시오. (메서드 오버로딩을 사용해 보자.) | ||
|
||
/** 정수 배열 사용 예 | ||
* | ||
* int[] data = {1, 3, 5, 7, 9}; | ||
* Calculator cal = new Calculator(); | ||
* int result = cal.avg(data); | ||
* System.out.println(result); // 5 출력 | ||
*/ | ||
public static void main(String[] args) { | ||
int[] data = {1, 3, 5, 7, 9}; | ||
Calculator cal = new Calculator(); | ||
int result = cal.avg(data); | ||
System.out.println(result); // 5 출력 | ||
|
||
/** 정수 리스트 사용 예 | ||
* ArrayList<Integer> data = new ArrayList<>(Arrays.asList(1, 3, 5, 7, 9)); | ||
* Calculator cal = new Calculator(); | ||
* int result = cal.avg(data); | ||
* System.out.println(result); // 5 출력 | ||
*/ | ||
ArrayList<Integer> data2 = new ArrayList<>(Arrays.asList(1, 3, 5, 7, 9)); | ||
Calculator cal2 = new Calculator(); | ||
int result2 = cal2.avg(data2); | ||
System.out.println(result2); | ||
} | ||
} |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
package Problem.yejun.Chapter5.Q7; | ||
|
||
class Bronze { | ||
class Bronze implements Mineral { | ||
|
||
@Override | ||
public int getValue() { | ||
return 80; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
package Problem.yejun.Chapter5.Q7; | ||
|
||
/** | ||
* 인터페이스 사용하기 다음은 광물의 가치를 계산하는 MineralCalculator 클래스와 그 사용법이 담긴 코드이다. 광물 계산기는 금인 경우 100, 은인 경우 90, 구리의 경우는 80의 가치를 더하는 | ||
* 기능(add 메스드)이 있다. | ||
*/ | ||
|
||
class Gold { | ||
class Gold implements Mineral { | ||
|
||
@Override | ||
public int getValue() { | ||
return 100; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package Problem.yejun.Chapter5.Q7; | ||
|
||
public interface Mineral { | ||
|
||
int getValue(); | ||
} |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
package Problem.yejun.Chapter5.Q7; | ||
|
||
class Silver { | ||
class Silver implements Mineral { | ||
|
||
@Override | ||
public int getValue() { | ||
return 90; | ||
} | ||
} |
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
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