This repository has been archived by the owner on Apr 16, 2024. It is now read-only.
-
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.
- Loading branch information
Showing
3 changed files
with
113 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package exam.test05; | ||
|
||
/** | ||
* Created by nhnent on 2017. 5. 27.. | ||
*/ | ||
public class Score { | ||
|
||
private String name; | ||
private float kor; | ||
private float eng; | ||
private float math; | ||
|
||
public Score() { | ||
|
||
} | ||
|
||
public Score(String name, float kor, float eng, float math) { | ||
this.name = name; | ||
this.kor = kor; | ||
this.eng = eng; | ||
this.math = math; | ||
} | ||
|
||
public float average() { | ||
return sum() / (float)3; | ||
} | ||
|
||
public float sum() { | ||
return kor + eng + math; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public float getKor() { | ||
return kor; | ||
} | ||
|
||
public void setKor(float kor) { | ||
this.kor = kor; | ||
} | ||
|
||
public float getEng() { | ||
return eng; | ||
} | ||
|
||
public void setEng(float eng) { | ||
this.eng = eng; | ||
} | ||
|
||
public float getMath() { | ||
return math; | ||
} | ||
|
||
public void setMath(float math) { | ||
this.math = math; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return name + ", " + kor + ", " + eng + ", " + math; | ||
} | ||
} |
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,17 @@ | ||
package exam.test05; | ||
|
||
import org.springframework.context.support.ClassPathXmlApplicationContext; | ||
|
||
/** | ||
* Created by nhnent on 2017. 5. 27.. | ||
*/ | ||
public class Test { | ||
|
||
public static void main(String[] args) { | ||
|
||
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("file:/Users/nhnent/workspace/workspace-intellij/java_webdev_workbook_spring/src/main/java/exam/test05/beans.xml"); | ||
|
||
System.out.println(ctx.getBean("score1")); | ||
System.out.println(ctx.getBean("score2")); | ||
} | ||
} |
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,28 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<beans xmlns="http://www.springframework.org/schema/beans" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://www.springframework.org/schema/beans | ||
http://www.springframework.org/schema/beans/spring-beans.xsd"> | ||
|
||
<bean id="score1" class="exam.test05.Score"> | ||
<property name="name"> | ||
<value>Hong Gildong</value> | ||
</property> | ||
<property name="kor"> | ||
<value>100</value> | ||
</property> | ||
<property name="eng"> | ||
<value>95</value> | ||
</property> | ||
<property name="math"> | ||
<value>90</value> | ||
</property> | ||
</bean> | ||
|
||
<bean id="score2" class="exam.test05.Score"> | ||
<property name="name" value="Lim Gukkjeon" /> | ||
<property name="kor" value="85" /> | ||
<property name="eng" value="99" /> | ||
<property name="math" value="100" /> | ||
</bean> | ||
</beans> |