esoe
2 years ago
28 changed files with 312 additions and 6 deletions
@ -0,0 +1,27 @@
@@ -0,0 +1,27 @@
|
||||
package ru.molokoin; |
||||
|
||||
public class App { |
||||
private Teacher[] teachers; |
||||
private Student[] students; |
||||
private Aspirant[] aspirants; |
||||
|
||||
//инициируем исходные данные
|
||||
App(){ |
||||
teachers = new Teacher[2]; |
||||
students = new Student[3]; |
||||
aspirants = new Aspirant[1]; |
||||
aspirants[0] = new Aspirant("Ronald Correa", Gender.MALE, "Computer science", "Design of a functional programming language."); |
||||
} |
||||
public void print(Person person){ |
||||
//
|
||||
} |
||||
//выводим данные в консоль
|
||||
public void printAll(){ |
||||
//
|
||||
} |
||||
|
||||
public static void main(String[] args) { |
||||
|
||||
} |
||||
|
||||
} |
@ -0,0 +1,24 @@
@@ -0,0 +1,24 @@
|
||||
package ru.molokoin; |
||||
|
||||
public class Aspirant extends Person{ |
||||
private String thesisTitle; |
||||
public static final Role role = Role.ASPIRANT; |
||||
|
||||
Aspirant (String name, Gender gender, String department, String thesisTitle) { |
||||
super(name, gender, department); |
||||
setThesisTitle(thesisTitle); |
||||
} |
||||
|
||||
public void setThesisTitle(String thesisTitle) { |
||||
this.thesisTitle = thesisTitle; |
||||
} |
||||
|
||||
public String getThesisTitle() { |
||||
return thesisTitle; |
||||
} |
||||
|
||||
public static void main(String[] args) { |
||||
|
||||
|
||||
} |
||||
} |
@ -1,5 +1,17 @@
@@ -1,5 +1,17 @@
|
||||
package ru.molokoin; |
||||
|
||||
public enum Degree { |
||||
|
||||
PhD { |
||||
@Override |
||||
public String getDegree() { |
||||
return "PhD"; |
||||
} |
||||
}, |
||||
MSc { |
||||
@Override |
||||
public String getDegree() { |
||||
return "MSc"; |
||||
} |
||||
}; |
||||
public abstract String getDegree(); |
||||
} |
||||
|
@ -1,5 +1,23 @@
@@ -1,5 +1,23 @@
|
||||
package ru.molokoin; |
||||
|
||||
/** |
||||
* Перечисление gender, |
||||
* |
||||
*/ |
||||
public enum Gender { |
||||
MALE, FEMALE |
||||
MALE { |
||||
public String getPronoun(){ |
||||
return "he"; |
||||
} |
||||
}, |
||||
FEMALE{ |
||||
public String getPronoun(){ |
||||
return "she"; |
||||
} |
||||
}, |
||||
TRANS{ |
||||
public String getPronoun() { |
||||
return "it"; |
||||
} |
||||
}; |
||||
public abstract String getPronoun(); |
||||
} |
||||
|
@ -1,7 +1,177 @@
@@ -1,7 +1,177 @@
|
||||
package ru.molokoin; |
||||
|
||||
public class Person { |
||||
String name; |
||||
Gender gender; |
||||
String department; |
||||
private String name; |
||||
private Gender gender; |
||||
private String department; |
||||
private Role role; |
||||
//для аспиранта
|
||||
private String thesisTitle; |
||||
//для преподавателя
|
||||
private Degree degree; |
||||
private String speciality; |
||||
//для студента
|
||||
private Stage stage; |
||||
private String course; |
||||
|
||||
/** |
||||
* Создаем персону |
||||
* @param name |
||||
* @param gender |
||||
* @param department |
||||
* @param role |
||||
*/ |
||||
Person(String name, Gender gender, String department, Role role){ |
||||
setName(name); |
||||
setGender(gender); |
||||
setDepartment(department); |
||||
setRole(role); |
||||
} |
||||
/** |
||||
* Создаем аспиранта |
||||
* @param name |
||||
* @param gender |
||||
* @param department |
||||
* @param role |
||||
* @param thesisTitle |
||||
*/ |
||||
Person(String name, Gender gender, String department, Role role, String thesisTitle){ |
||||
this(name, gender, department, role); |
||||
setThesisTitle(thesisTitle); |
||||
} |
||||
|
||||
/** |
||||
* Создаем преподавателя |
||||
* @param name |
||||
* @param gender |
||||
* @param department |
||||
* @param role |
||||
* @param degree |
||||
* @param speciality |
||||
*/ |
||||
Person(String name, Gender gender, String department, Role role, Degree degree, String speciality){ |
||||
this(name, gender, department, role); |
||||
setDegree(degree); |
||||
setSpeciality(speciality); |
||||
} |
||||
|
||||
/** |
||||
* Создаем студента |
||||
* @param name |
||||
* @param gender |
||||
* @param department |
||||
* @param role |
||||
* @param stage |
||||
* @param course |
||||
*/ |
||||
Person(String name, Gender gender, String department, Role role, Stage stage, String course){ |
||||
this(name, gender, department, role); |
||||
setStage(stage); |
||||
setCourse(course); |
||||
} |
||||
|
||||
public static Person[] initDefaults(){ |
||||
Person[] defaultList = new Person[6]; |
||||
defaultList[0] = new Person("Ronald Turner", Gender.MALE, "Computer science", Role.TEACHER); |
||||
defaultList[1] = new Person("Ruth Hollings", Gender.FEMALE, "Jurisprudence", Role.TEACHER); |
||||
defaultList[2] = new Person("Leo Wilkinson", Gender.MALE, "Computer science", Role.STUDENT); |
||||
defaultList[3] = new Person("Anna Cunningham", Gender.FEMALE, "World economy", Role.STUDENT); |
||||
defaultList[4] = new Person("Jill Lundqvist", Gender.FEMALE, "Jurisprudence", Role.STUDENT); |
||||
defaultList[5] = new Person("Ronald Correa", Gender.MALE, "Computer science", Role.ASPIRANT); |
||||
return defaultList; |
||||
} |
||||
/** |
||||
* Выводит общие данные о персоне в консоль |
||||
*/ |
||||
public void print(){ |
||||
System.out.println("This is {name}. {He/she} {verb} at {department}"); |
||||
} |
||||
|
||||
/** |
||||
* Устанавливает значение поля name/Фамилия, Имя и Отчество человека |
||||
* @param name |
||||
* не может быть пустым, если передано пустое значение, устанавливается значение noname |
||||
*/ |
||||
public void setName(String name) { |
||||
this.name = name; |
||||
} |
||||
public void setGender(Gender gender) { |
||||
this.gender = gender; |
||||
} |
||||
public void setDepartment(String department) { |
||||
this.department = department; |
||||
} |
||||
public void setRole(Role role) { |
||||
this.role = role; |
||||
} |
||||
public void setThesisTitle(String thesisTitle) { |
||||
this.thesisTitle = thesisTitle; |
||||
} |
||||
public void setDegree(Degree degree) { |
||||
this.degree = degree; |
||||
} |
||||
public void setSpeciality(String speciality) { |
||||
this.speciality = speciality; |
||||
} |
||||
public void setStage(Stage stage) { |
||||
this.stage = stage; |
||||
} |
||||
public void setCourse(String course) { |
||||
this.course = course; |
||||
} |
||||
|
||||
/** |
||||
* |
||||
*/ |
||||
|
||||
/** |
||||
* Возвращает имя человека, |
||||
* TODO имя не может быть пустым полем или отсутствовать |
||||
* @return |
||||
*/ |
||||
public String getName() { |
||||
return name; |
||||
} |
||||
/** |
||||
* возвращает пол/gender человека мужской/male или женский/female |
||||
* @return |
||||
* |
||||
*/ |
||||
public Gender getGender() { |
||||
return gender; |
||||
} |
||||
/** |
||||
* Возвращает наименование департамента, в котором трудится человек (учится или преподает) |
||||
* @return |
||||
* |
||||
*/ |
||||
public String getDepartment() { |
||||
return department; |
||||
} |
||||
public Role getRole() { |
||||
return role; |
||||
} |
||||
public String getThesisTitle() { |
||||
return thesisTitle; |
||||
} |
||||
public Degree getDegree() { |
||||
return degree; |
||||
} |
||||
public String getSpeciality() { |
||||
return speciality; |
||||
} |
||||
public Stage getStage() { |
||||
return stage; |
||||
} |
||||
public String getCourse() { |
||||
return course; |
||||
} |
||||
public static void main(String[] args) { |
||||
Person[] list = Person.initDefaults(); |
||||
int i = 0; |
||||
while (i < list.length){ |
||||
list[i].print(); |
||||
i++; |
||||
} |
||||
} |
||||
} |
||||
|
@ -0,0 +1,23 @@
@@ -0,0 +1,23 @@
|
||||
package ru.molokoin; |
||||
|
||||
public enum Role { |
||||
STUDENT { |
||||
@Override |
||||
public String getVerb() { |
||||
return "studies"; |
||||
} |
||||
}, |
||||
ASPIRANT { |
||||
@Override |
||||
public String getVerb() { |
||||
return "studies"; |
||||
} |
||||
}, |
||||
TEACHER { |
||||
@Override |
||||
public String getVerb() { |
||||
return "teaches"; |
||||
} |
||||
}; |
||||
public abstract String getVerb(); |
||||
} |
@ -0,0 +1,17 @@
@@ -0,0 +1,17 @@
|
||||
package ru.molokoin; |
||||
|
||||
public enum Stage { |
||||
bachelor { |
||||
@Override |
||||
public String getStage() { |
||||
return "bachelor"; |
||||
} |
||||
}, |
||||
master { |
||||
@Override |
||||
public String getStage() { |
||||
return "master"; |
||||
} |
||||
}; |
||||
public abstract String getStage(); |
||||
} |
@ -0,0 +1,5 @@
@@ -0,0 +1,5 @@
|
||||
package ru.molokoin; |
||||
|
||||
public class Student extends Person{ |
||||
public static final Role role = Role.STUDENT; |
||||
} |
@ -0,0 +1,10 @@
@@ -0,0 +1,10 @@
|
||||
package ru.molokoin; |
||||
|
||||
public class Teacher extends Person{ |
||||
public static final Role role = Role.TEACHER; |
||||
|
||||
Teacher(String name, Gender gender, String department) { |
||||
super(name, gender, department); |
||||
//
|
||||
} |
||||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in new issue