esoe 2 years ago
parent
commit
452e262583
  1. 27
      universaty/src/main/java/ru/molokoin/App.java
  2. 24
      universaty/src/main/java/ru/molokoin/Aspirant.java
  3. 14
      universaty/src/main/java/ru/molokoin/Degree.java
  4. 22
      universaty/src/main/java/ru/molokoin/Gender.java
  5. 176
      universaty/src/main/java/ru/molokoin/Person.java
  6. 23
      universaty/src/main/java/ru/molokoin/Role.java
  7. 17
      universaty/src/main/java/ru/molokoin/Stage.java
  8. 5
      universaty/src/main/java/ru/molokoin/Student.java
  9. 10
      universaty/src/main/java/ru/molokoin/Teacher.java
  10. BIN
      universaty/target/classes/ru/molokoin/App.class
  11. BIN
      universaty/target/classes/ru/molokoin/Aspirant.class
  12. BIN
      universaty/target/classes/ru/molokoin/Degree$1.class
  13. BIN
      universaty/target/classes/ru/molokoin/Degree$2.class
  14. BIN
      universaty/target/classes/ru/molokoin/Degree.class
  15. BIN
      universaty/target/classes/ru/molokoin/Gender$1.class
  16. BIN
      universaty/target/classes/ru/molokoin/Gender$2.class
  17. BIN
      universaty/target/classes/ru/molokoin/Gender$3.class
  18. BIN
      universaty/target/classes/ru/molokoin/Gender.class
  19. BIN
      universaty/target/classes/ru/molokoin/Person.class
  20. BIN
      universaty/target/classes/ru/molokoin/Role$1.class
  21. BIN
      universaty/target/classes/ru/molokoin/Role$2.class
  22. BIN
      universaty/target/classes/ru/molokoin/Role$3.class
  23. BIN
      universaty/target/classes/ru/molokoin/Role.class
  24. BIN
      universaty/target/classes/ru/molokoin/Stage$1.class
  25. BIN
      universaty/target/classes/ru/molokoin/Stage$2.class
  26. BIN
      universaty/target/classes/ru/molokoin/Stage.class
  27. BIN
      universaty/target/classes/ru/molokoin/Student.class
  28. BIN
      universaty/target/classes/ru/molokoin/Teacher.class

27
universaty/src/main/java/ru/molokoin/App.java

@ -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) {
}
}

24
universaty/src/main/java/ru/molokoin/Aspirant.java

@ -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) {
}
}

14
universaty/src/main/java/ru/molokoin/Degree.java

@ -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();
}

22
universaty/src/main/java/ru/molokoin/Gender.java

@ -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();
}

176
universaty/src/main/java/ru/molokoin/Person.java

@ -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++;
}
}
}

23
universaty/src/main/java/ru/molokoin/Role.java

@ -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();
}

17
universaty/src/main/java/ru/molokoin/Stage.java

@ -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();
}

5
universaty/src/main/java/ru/molokoin/Student.java

@ -0,0 +1,5 @@ @@ -0,0 +1,5 @@
package ru.molokoin;
public class Student extends Person{
public static final Role role = Role.STUDENT;
}

10
universaty/src/main/java/ru/molokoin/Teacher.java

@ -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);
//
}
}

BIN
universaty/target/classes/ru/molokoin/App.class

Binary file not shown.

BIN
universaty/target/classes/ru/molokoin/Aspirant.class

Binary file not shown.

BIN
universaty/target/classes/ru/molokoin/Degree$1.class

Binary file not shown.

BIN
universaty/target/classes/ru/molokoin/Degree$2.class

Binary file not shown.

BIN
universaty/target/classes/ru/molokoin/Degree.class

Binary file not shown.

BIN
universaty/target/classes/ru/molokoin/Gender$1.class

Binary file not shown.

BIN
universaty/target/classes/ru/molokoin/Gender$2.class

Binary file not shown.

BIN
universaty/target/classes/ru/molokoin/Gender$3.class

Binary file not shown.

BIN
universaty/target/classes/ru/molokoin/Gender.class

Binary file not shown.

BIN
universaty/target/classes/ru/molokoin/Person.class

Binary file not shown.

BIN
universaty/target/classes/ru/molokoin/Role$1.class

Binary file not shown.

BIN
universaty/target/classes/ru/molokoin/Role$2.class

Binary file not shown.

BIN
universaty/target/classes/ru/molokoin/Role$3.class

Binary file not shown.

BIN
universaty/target/classes/ru/molokoin/Role.class

Binary file not shown.

BIN
universaty/target/classes/ru/molokoin/Stage$1.class

Binary file not shown.

BIN
universaty/target/classes/ru/molokoin/Stage$2.class

Binary file not shown.

BIN
universaty/target/classes/ru/molokoin/Stage.class

Binary file not shown.

BIN
universaty/target/classes/ru/molokoin/Student.class

Binary file not shown.

BIN
universaty/target/classes/ru/molokoin/Teacher.class

Binary file not shown.
Loading…
Cancel
Save