Tutorial 4 Lecturer: Craig MacDonald Tutorial: Mon@10:10am 971006 ========== CSC 108, Fall 1997 Tutorial notes, T4 ========================================================================== Take up the example of the one class that has a field which is an object of another class. The Circle class HAS a Center (Point object) and HAS a radius (primitive). I will be finished chapter 5 by then so if you have time here are some more topics. Do an example that illustrates precedence such as boolean b = new MyClass().returnNum("1." + "03") - num > 1.0 || c; Choose a better example than this or use this. Get them to reason about this expression. Even without knowing about MyClass, this expression only makes sense if returnNum takes a string as an argument and returns a double. Ask them about the "signature" of the returnNum method. Do any example of narrowing conversions causing loss of magnitude such as int to float. Text page 178. questions 4.13 factorial (non recursive please) public int Factorial (int n) { prod = 1; for (int i=1 ; i<=n ; i++) prod *= i; return prod; } one of 4.14 - 4.17 4.19 ask them what fields are needed to accomplish the goals required in the methods don't fill this out with code just create empty methods. They should tell you how to do this. 5.9 (a) and 5.10 (b) decimal to/from twos complement binary conversions Again I have given you too much to cover. Go slowly and don't worry about completing this. Do tell me how far you get, though. The first assignment is due on Oct 10. Craig