CS 50 Homework 8 (Section 1 — Prof. Marshall)

Due by class time Tuesday, April 2
  1. Programming Exercises P9.3 and P9.12 (pages 392-393). Provide a single test program called "TestPerson" that asks the user for five Student names and five Instructor names, generates the appropriate objects, and then uses compareTo to print out the first and last person as determined by the alphabetical ordering of their names. You may use Vectors or arrays for this problem if you like, but they aren't necessary. Files to submit: Person.java, Student.java, Instructor.java, Comparable.java, TestPerson.java

  2. Programming Exercise P9.4 (page 392). Files to submit: Employee.java, Manager.java, Executive.java, TestEmployee.java

  3. Programming Exercise P11.7 (page 473). Use TestSame.java as your starting point for this problem. Files to submit: TestSame.java

  4. Programming Exercise P11.10 (page 474), with the following modification: use Vectors instead of arrays. That is, create a second Vector and fill it with the numbers 1 through 10. Then repeatedly pick a number from this Vector at random, remove it, and append it to the permutation Vector. Your program should print out ten different random permutations of the numbers 1 through 10. Name your test program "RandomPerms". Files to submit: RandomPerms.java

  5. Programming Exercise P11.15 (page 475). Name your program "TestMagic". Files to submit: TestMagic.java


EXTRA CREDIT PROBLEM

  1. Programming Exercise P11.14 (page 475). Have the players enter their moves via an input dialog instead of the mouse. Name your applet program and HTML file "TicTacToe". Files to submit: TicTacToe.java, TicTacToe.html


Turning in Your Homework

To turn in your homework, put the specified files into a single folder named Your Name HW 8 and drop this folder into the drop box. If you are an off-campus student, you may copy your folder to a CLEAN floppy disk (one containing no other files or folders), and hand this in at the beginning of class, instead of using the drop box.