5段階目(EmployeeDataにコンストラクタを作ろう)
This commit is contained in:
@@ -7,6 +7,22 @@ public class EmployeeData {
|
|||||||
private String password;
|
private String password;
|
||||||
private String idDepartment;
|
private String idDepartment;
|
||||||
|
|
||||||
|
//コンストラクタ
|
||||||
|
public EmployeeData() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//引数ありコンストラクタ
|
||||||
|
public EmployeeData(String idEmployee, String nmEmployee, String knEmployee,
|
||||||
|
String mailAddress, String password, String idDepartment) {
|
||||||
|
this.setIdEmployee(idEmployee);
|
||||||
|
this.setNmEmployee(nmEmployee);
|
||||||
|
this.setKnEmployee(knEmployee);
|
||||||
|
this.setMailAddress(mailAddress);
|
||||||
|
this.setPassword(password);
|
||||||
|
this.setIdDepartment(idDepartment);
|
||||||
|
}
|
||||||
|
|
||||||
void showInfo() {
|
void showInfo() {
|
||||||
System.out.println(this.idEmployee + "\t" + this.nmEmployee
|
System.out.println(this.idEmployee + "\t" + this.nmEmployee
|
||||||
+ "\t" + this.knEmployee + "\t" + this.mailAddress
|
+ "\t" + this.knEmployee + "\t" + this.mailAddress
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
EmployeeData employee = new EmployeeData("10000", "山田龍也", "ヤマダタツヤ",
|
||||||
|
"yamada@hoge.jp", "aaa", "10");
|
||||||
|
employee.showInfo();
|
||||||
|
|
||||||
EmployeeData[] employees = new EmployeeData[5];
|
EmployeeData[] employees = new EmployeeData[5];
|
||||||
for (int i = 0; i < employees.length; i++) {
|
for (int i = 0; i < employees.length; i++) {
|
||||||
employees[i] = new EmployeeData();
|
employees[i] = new EmployeeData();
|
||||||
|
|||||||
Reference in New Issue
Block a user