Exemplo n.º 1
0
 public void FireInstructorAndHireAnother(string inJmbgFire, string inNameHire, string inSurnameHire,
     string inJmbgHire)
 {
     long n;
     if (!long.TryParse(inJmbgFire, out n) || !long.TryParse(inJmbgHire, out n))
         throw new GyManagerException("JMBG must contain only digits.");
     if (inJmbgFire.Length != 13 || inJmbgHire.Length != 13)
         throw new GyManagerException("JMBG must contain 13 digits.");
     if (members.ContainsKey(inJmbgHire)) throw new GyManagerException("Person with that JMBG is a member.");
     Instructor firedInstructor = instructors[inJmbgFire];
     Instructor hiredInstructor = new Instructor(inNameHire, inSurnameHire, inJmbgHire, firedInstructor.program);
     Program program = programs[firedInstructor.program];
     program.instructor = inJmbgHire;
     instructors.Remove(inJmbgFire);
     instructors.Add(inJmbgHire, hiredInstructor);
     NotifyObservers();
 }
Exemplo n.º 2
0
 public void AddProgramAndInstructor(string inProgramName, int inPrice, int inPlacesAvailable,
     string inInstructorName,
     string inInstructorSurname, string inJmbg, int inSalary)
 {
     long n;
     if (!long.TryParse(inJmbg, out n)) throw new GyManagerException("JMBG must contain only digits.");
     if (inJmbg.Length != 13) throw new GyManagerException("JMBG must contain 13 digits.");
     if (instructors.ContainsKey(inJmbg))
         throw new GyManagerException("Instructor with that JMBG already exists.");
     if (programs.ContainsKey(inProgramName))
         throw new GyManagerException("Program with that name already exists.");
     if (members.ContainsKey(inJmbg)) throw new GyManagerException("Person with that JMBG is a member.");
     Program newProgram = new Program(inProgramName, inPrice, inPlacesAvailable, inJmbg, inSalary);
     programs.Add(inProgramName, newProgram);
     Instructor newInstructor = new Instructor(inInstructorName, inInstructorSurname, inJmbg, inProgramName);
     instructors.Add(inJmbg, newInstructor);
     NotifyObservers();
 }