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 IEEE Xtreme Competition Probably not too late to register… SE-1011 Slide design: Dr. Mark L. Hornick Instructor: Dr. Yoder 2

3 Muddiest Point (1) Is having so many methods in a class a typical thing?many methods Whenever I make methods it requires inputs and I'm never sure what to put in terms of variables.designing methods I'm a bit confused about the order in which methods are used.calling methods can clock reference the main code? Main can read clock but can clock read main? references and encapsulation How to print the variables from another classcalling methods Is the tick something that you created or something that was preset in java?defining methods when to use "this.xxx"this When would we want unnecessary decimal points? (# instead of 0)DecimalFormat 3 Key: bold – discussed this class; italics – discussed at start; underline – discussed in lecture

4 Muddiest Point (2) Why have two objects pointing to one reference (Why have clock and clock2, instead of just using clock for everything?)multiple references 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 Why "sleep" or "waiting" is so complicated; or why java can't do two things at oncemultithreading why would yu want two references to the same thing?multiple references some confusion with the formattingDecimalFormat How to call an output from a class?return values? the clock counted one minute per second?yes, for testing What is a UML (lab 6) document?UML 4 Key: bold – discussed this class; italics – discussed at start; underline – discussed in lecture

5 UML class diagrams – Designing classes SE-1011 Slide design: Dr. Mark L. Hornick Instructor: Dr. Yoder 5 Clock - hours: int - minutes: int + setTime(hrs: int, min: int): void + setHours(hrs: int): void + tick(): void - countMinuteForward(): void + toString(): String

6 Yogurt Simulator We (or at least I) would like to write a yogurt incubation simulator. Yogurt is milk cultured with bacteria. Each bacterium is a single-celled organism that eats milk and produces yogurt. To culture yogurt, we put some number of bacteria into warm milk. As time goes by, the bacteria reproduce, making more bacteria to culture the milk faster. The number of bacteria at the end of an hour is 10% more than the number at the beginning of that hour. 6

7 Yoghurt Simulator Exercise 1: Choose a variable to model the yoghurt-making process. You do not need to model the milk and yoghurt, just the growth of the bacterium. Exercise 2: Brainstorm a list of possible behaviors for the yoghurt simulator. SE-1011 Slide design: Dr. Mark L. Hornick Instructor: Dr. Yoder 7

8 Yoghurt Simulator Exercise: Write a complete UML diagram like the one on an earlier slide for the Clock class SE-1011 Slide design: Dr. Mark L. Hornick Instructor: Dr. Yoder 8

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 Point A 285638 Incubator numBacteria long 0

10 How to add culture to incubator? SE-1011 Slide design: Dr. Mark L. Hornick Instructor: Dr. Yoder 10 Incubator ref incubator 285638 main(…) 0.125 cupsCulture double addStarterCups(…) Point B Incubator ref this 285638 Incubator numBacteria long 0

11 How to add culture to incubator? SE-1011 Slide design: Dr. Mark L. Hornick Instructor: Dr. Yoder 11 Incubator ref incubator 285638 main(…) 0.125 cupsCulture double addStarterCups(…) Point C Incubator ref this 285638 2_500_000_000 newBacteria long 285638 Incubator numBacteria long 0

12 How to add culture to incubator? SE-1011 Slide design: Dr. Mark L. Hornick Instructor: Dr. Yoder 12 Incubator ref incubator 285638 main(…) 0.125 cupsCulture double addStarterCups(…) Point D Incubator ref this 285638 Incubator 2_500_000_000 numBacteria long 2_500_000_000 newBacteria long

13 How to print a class variable? SE-1011 Slide design: Dr. Mark L. Hornick Instructor: Dr. Yoder 13 Incubator ref incubator 285638 main(…) 0.125 cupsCulture double Point E 285638 Incubator 2_500_000_000 numBacteria long

14 How to print a class variable? SE-1011 Slide design: Dr. Mark L. Hornick Instructor: Dr. Yoder 14 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

15 Lab 6 UML Document Complete before lab Write on a sheet of paper Include all elements discussed today class name public/private visibility symbols all methods, all instance variables all types, including return types, including void formatting: boxes, colons, etc. SE-1011 Slide design: Dr. Mark L. Hornick Instructor: Dr. Yoder 15

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

17 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 17


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