Compare commits
2 Commits
cbbfae71fb
...
f1ffaf5116
| Author | SHA1 | Date | |
|---|---|---|---|
| f1ffaf5116 | |||
| bd691238e7 |
@@ -7,20 +7,19 @@ public class EmployeeData {
|
|||||||
private String password;
|
private String password;
|
||||||
private String idDepartment;
|
private String idDepartment;
|
||||||
private static int empCount = 0;
|
private static int empCount = 0;
|
||||||
|
|
||||||
static final String COMPANY_NAME = "Rhizome";
|
static final String COMPANY_NAME = "Rhizome";
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return getIdEmployee() + "\t" + getNmEmployee() + " " + getKnEmployee() + "\t" + getMailAddress()
|
return getIdEmployee() + "\t" + getNmEmployee() + " " + getKnEmployee() + "\t" + getMailAddress()
|
||||||
+ "\t" + getPassword() + "\t" + getIdDepartment();
|
+ "\t" + getPassword() + "\t" + getIdDepartment();
|
||||||
}
|
}
|
||||||
|
|
||||||
static int getEmpCount() {
|
static int getEmpCount() {
|
||||||
return empCount;
|
return empCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
//getNmEmployee.strip();
|
//getNmEmployee.strip();
|
||||||
|
|
||||||
public EmployeeData() {
|
public EmployeeData() {
|
||||||
@@ -30,24 +29,30 @@ public class EmployeeData {
|
|||||||
|
|
||||||
public EmployeeData(String idEmployee, String nmEmployee, String knEmployee, String mailAddress, String password,
|
public EmployeeData(String idEmployee, String nmEmployee, String knEmployee, String mailAddress, String password,
|
||||||
String idDepartment) {
|
String idDepartment) {
|
||||||
|
|
||||||
nmEmployee=nmEmployee.strip();
|
nmEmployee = nmEmployee.strip();
|
||||||
int nmNum = nmEmployee.length();
|
int nmNum = nmEmployee.length();
|
||||||
|
|
||||||
if(nmNum==0) {
|
idEmployee = idEmployee.strip();
|
||||||
|
int idNum = idEmployee.length();
|
||||||
|
|
||||||
|
if (nmNum == 0) {
|
||||||
System.out.println("社員名が空のため設定できませんでした");
|
System.out.println("社員名が空のため設定できませんでした");
|
||||||
|
|
||||||
}
|
}
|
||||||
if(nmNum>0){
|
if (idNum == 0) {
|
||||||
|
System.out.println("社員IDが空のため設定できませんでした");
|
||||||
|
}
|
||||||
this.setIdEmployee(idEmployee);
|
if (nmNum > 0 && idNum > 0) {
|
||||||
this.setNmEmployee(nmEmployee);
|
|
||||||
this.setKnEmployee(knEmployee);
|
this.setIdEmployee(idEmployee);
|
||||||
this.setMailAddress(mailAddress);
|
this.setNmEmployee(nmEmployee);
|
||||||
this.setPassword(password);
|
this.setKnEmployee(knEmployee);
|
||||||
this.setIdDepartment(idDepartment);
|
this.setMailAddress(mailAddress);
|
||||||
empCount++;
|
this.setPassword(password);
|
||||||
|
this.setIdDepartment(idDepartment);
|
||||||
|
empCount++;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,7 +61,7 @@ public class EmployeeData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setIdEmployee(String idEmployee) {
|
public void setIdEmployee(String idEmployee) {
|
||||||
|
|
||||||
this.idEmployee = idEmployee;
|
this.idEmployee = idEmployee;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,8 +105,4 @@ public class EmployeeData {
|
|||||||
this.idDepartment = idDepartment;
|
this.idDepartment = idDepartment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
public class Main {
|
public class Main {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
EmployeeData[] employee = new EmployeeData[5];
|
EmployeeData[] employee = new EmployeeData[5];
|
||||||
employee[0] = new EmployeeData("10000"," ","ヤマダタツヤ","yamada@hoge.jp","aaa","10");
|
employee[0] = new EmployeeData("10000","","ヤマダタツヤ","yamada@hoge.jp","aaa","10");
|
||||||
employee[1] = new EmployeeData();
|
employee[1] = new EmployeeData();
|
||||||
employee[2] = new EmployeeData();
|
employee[2] = new EmployeeData();
|
||||||
employee[3] = new EmployeeData();
|
employee[3] = new EmployeeData();
|
||||||
@@ -48,6 +48,9 @@ public class Main {
|
|||||||
|
|
||||||
|
|
||||||
for(int i=0;i<5;i++) {
|
for(int i=0;i<5;i++) {
|
||||||
|
if(employee[i].getNmEmployee()==null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
System.out.println(employee[i]);
|
System.out.println(employee[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
22
em-oop/src/day3_123/Circle.java
Normal file
22
em-oop/src/day3_123/Circle.java
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
package day3_123;
|
||||||
|
|
||||||
|
public class Circle extends Shape {
|
||||||
|
private double radius;
|
||||||
|
|
||||||
|
public Circle(double radius) {
|
||||||
|
super("円");
|
||||||
|
this.radius=radius;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double area() {
|
||||||
|
return Math.PI*radius*radius;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void showInfo() {
|
||||||
|
super.showInfo();
|
||||||
|
System.out.println("(半径:"+this.radius+")");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
10
em-oop/src/day3_123/Day3Check1.java
Normal file
10
em-oop/src/day3_123/Day3Check1.java
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
package day3_123;
|
||||||
|
|
||||||
|
public class Day3Check1 {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
Circle circle=new Circle(2);
|
||||||
|
circle.showInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
15
em-oop/src/day3_123/Shape.java
Normal file
15
em-oop/src/day3_123/Shape.java
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
package day3_123;
|
||||||
|
|
||||||
|
public abstract class Shape {
|
||||||
|
private String name;
|
||||||
|
public Shape(String name) {
|
||||||
|
this.name=name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract double area();
|
||||||
|
|
||||||
|
public void showInfo() {
|
||||||
|
System.out.println(this.name+"の面積は"+this.area()+"です");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user