Exercises

November 15-17, 2006

  1. Implement a class LoginGenerator. The class should have two static methods, both named generateLogin. The first method will take as input two Strings representing the first name and last name and return a String containing the first character of the first name, the first five characters of the last name, and a random number in the range 10-99. The second method will take as input one String representing the last name and will return a String containing the first five characters of the last name and a random number in the range 10-99. Make sure to handle the possible error that would occur if the last name were shorter than 5 characters.
  2. Design and implement a class Course that contains information about a course taken at a school (for example, the course number, name, and instructor). Provide appropriate accessor and modifier methods for the Course class. Next, implement a class Student that contains the name of a student, the user login for the student, and up to four courses for which the student is registered. The Student constructor should take the first and last name of the student and use the GenerateLogin class to generate the Student's user login. Implement a method that takes as input a String representing the name of an instructor and returns true if the student is taking a course taught by the instructor represented by the String input and false otherwise. Make sure to provide any other appropriate accessor and modifier methods for the Student class. (Hint: you will need to figure out how to specify that a student is taking a particular class.)


Sami Rollins