Presentation is loading. Please wait.

Presentation is loading. Please wait.

SE1011 Week 6, Class 2 Today Return Half Exam 2 (cont.) Object Oriented Programming (cont.) UML class diagrams Muddiest Point Next Half Exam: Week 7, Monday.

Similar presentations


Presentation on theme: "SE1011 Week 6, Class 2 Today Return Half Exam 2 (cont.) Object Oriented Programming (cont.) UML class diagrams Muddiest Point Next Half Exam: Week 7, Monday."— Presentation transcript:

1 SE1011 Week 6, Class 2 Today Return Half Exam 2 (cont.) Object Oriented Programming (cont.) UML class diagrams Muddiest Point Next Half Exam: Week 7, Monday SE-1011 Slide design: Dr. Mark L. Hornick Instructor: Dr. Yoder 1

2 Old Muddy Points I'm a bit confused about the order in which methods are used.calling methods How to print the variables from another classreturning values when to use "this.xxx"this When would we want unnecessary decimal points? (# instead of 0)DecimalFormat I getting confused between objects and addresses and the actual clock codememory & code I would like to know if there are any syntax choice preferences you have that you would like us to use.syntax How to call an output from a class?returning values? 2 Key: bold – discussed this class; italics – discussed at start; underline – discussed in lecture

3 Muddiest Point (1) what is "static"?static - later I like that UML states clearly the methods and variables we are using. I only got confused in the last 10 mins of classmemory diagrams how to know when to make it public or private and also how to know if it is void or otherwise. public/private, returning values In the UML diagram, for methods when the return is not void, do we specify the type that is returned or the variable that is returned?UML: returning values Is UML basically a universal pseudocode? UML. Yes, but there are many forms bigger value than long? Yes - See BigInteger and BigDecimal 3 Key: bold – discussed this class; italics – discussed at start; underline – discussed in lecture

4 Muddiest Point (2) how to print variables from other classesreturning values How do you know when to use a private method? Should you just know or do you come back and find out later?public/private scope of variables between classespublic/private Would two references to the same object ever be useful in main?No - not yet Some of the PPT layout slides where the variables and methods are laid out are confusing. The actual java code makes more sense to mememory diagrams timing? 4 Key: bold – discussed this class; italics – discussed at start; underline – discussed in lecture

5 Scope A variable's scope is where it is visible This is determined by local / instance (local only visible in method) life of variable (local only "lives" to end of block) public / private (instance only visible in class unless public) SE-1011 Slide design: Dr. Mark L. Hornick Instructor: Dr. Yoder 5

6 How to add culture to incubator? SE-1011 Slide design: Dr. Mark L. Hornick Instructor: Dr. Yoder 6 Incubator ref incubator 285638 main(…) 0.125 cupsCulture double Point A 285638 Incubator numBacteria long 0 In YogurtDriver 's main(…) Incubator incubator = new Incubator(); // Point A incubator.addStarterCups((double)1/8);

7 How to add culture to incubator? SE-1011 Slide design: Dr. Mark L. Hornick Instructor: Dr. Yoder 7 Incubator ref incubator 285638 main(…) 0.125 cupsCulture double addStarterCups(…) Point B 285638 Incubator numBacteria long 0 in Incubator 's addStarterCups(…) // Point B long newBacteria = (long)(starterCups * BACTERIA_PER_CUP_STARTER); Incubator ref this 285638 0.125 starterCups double

8 How to add culture to incubator? SE-1011 Slide design: Dr. Mark L. Hornick Instructor: Dr. Yoder 8 Incubator ref incubator 285638 main(…) 0.125 cupsCulture double addStarterCups(…) Point C Incubator ref this 285638 Incubator numBacteria long 0 in Incubator 's addStarterCups(…) long newBacteria = (long)(starterCups * BACTERIA_PER_CUP_STARTER); // Point C numBacteria += newBacteria; 0.125 starterCups double 2_500_000_000 newBacteria long

9 How to add culture to incubator? SE-1011 Slide design: Dr. Mark L. Hornick Instructor: Dr. Yoder 9 Incubator ref incubator 285638 main(…) 0.125 cupsCulture double addStarterCups(…) Point D 285638 Incubator 2_500_000_000 numBacteria long in Incubator 's addStarterCups(…) numBacteria += newBacteria; // Point D Incubator ref this 285638 0.125 starterCups double 2_500_000_000 newBacteria long

10 How to print a class variable? SE-1011 Slide design: Dr. Mark L. Hornick Instructor: Dr. Yoder 10 Incubator ref incubator 285638 main(…) 0.125 cupsCulture double Point E 285638 Incubator 2_500_000_000 numBacteria long In YogurtDriver 's main(…) incubator.addStarterCups((double)1/8); // Point E

11 How to print a class variable? SE-1011 Slide design: Dr. Mark L. Hornick Instructor: Dr. Yoder 11 Incubator ref incubator 285638 main(…) 0.125 cupsCulture double getNumBacteria(…) Point F 285638 Incubator 2_500_000_000 numBacteria long Complete this part. Also, what value is returned? SE1011 Week 6, Class 2 in Incubator 's getNumBacteria() // Point F return numBacteria;

12 SE-1011 Slide design: Dr. Mark L. Hornick Instructor: Dr. Yoder 12

13 Acknowledgement This course is based on the text Introduction to Programming with Java by Dean & Dean, 2 nd Edition SE-1011 Slide design: Dr. Mark L. Hornick Instructor: Dr. Yoder 13


Download ppt "SE1011 Week 6, Class 2 Today Return Half Exam 2 (cont.) Object Oriented Programming (cont.) UML class diagrams Muddiest Point Next Half Exam: Week 7, Monday."

Similar presentations


Ads by Google