/*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ package example; import java.util.*; // line 3 "../UnidirectionalNTest.ump" public class Mentor { //------------------------ // MEMBER VARIABLES //------------------------ //Mentor Attributes private String name; //Mentor Associations private List<Student> students; //------------------------ // CONSTRUCTOR //------------------------ public Mentor(String aName, Student... allStudents) { name = aName; students = new ArrayList<Student>(); boolean didAddStudents = setStudents(allStudents); if (!didAddStudents) { throw new RuntimeException("Unable to create Mentor, must have 4 students. See https://manual.umple.org?RE002ViolationofAssociationMultiplicity.html"); } } //------------------------ // INTERFACE //------------------------ public boolean setName(String aName) { boolean wasSet = false; name = aName; wasSet = true; return wasSet; } public String getName() { return name; } /* Code from template association_GetMany */ public Student getStudent(int index) { Student aStudent = students.get(index); return aStudent; } public List<Student> getStudents() { List<Student> newStudents = Collections.unmodifiableList(students); return newStudents; } public int numberOfStudents() { int number = students.size(); return number; } public boolean hasStudents() { boolean has = students.size() > 0; return has; } public int indexOfStudent(Student aStudent) { int index = students.indexOf(aStudent); return index; } /* Code from template association_RequiredNumberOfMethod */ public static int requiredNumberOfStudents() { return 4; } /* Code from template association_MinimumNumberOfMethod */ public static int minimumNumberOfStudents() { return 4; } /* Code from template association_MaximumNumberOfMethod */ public static int maximumNumberOfStudents() { return 4; } /* Code from template association_SetUnidirectionalN */ public boolean setStudents(Student... newStudents) { boolean wasSet = false; ArrayList<Student> verifiedStudents = new ArrayList<Student>(); for (Student aStudent : newStudents) { if (verifiedStudents.contains(aStudent)) { continue; } verifiedStudents.add(aStudent); } if (verifiedStudents.size() != newStudents.length || verifiedStudents.size() != requiredNumberOfStudents()) { return wasSet; } students.clear(); students.addAll(verifiedStudents); wasSet = true; return wasSet; } public void delete() { students.clear(); } public String toString() { return super.toString() + "["+ "name" + ":" + getName()+ "]"; } } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ package example; // line 9 "../UnidirectionalNTest.ump" public class Student { //------------------------ // MEMBER VARIABLES //------------------------ //Student Attributes private String number; //------------------------ // CONSTRUCTOR //------------------------ public Student(String aNumber) { number = aNumber; } //------------------------ // INTERFACE //------------------------ public boolean setNumber(String aNumber) { boolean wasSet = false; number = aNumber; wasSet = true; return wasSet; } public String getNumber() { return number; } public void delete() {} public String toString() { return super.toString() + "["+ "number" + ":" + getNumber()+ "]"; } }