1 / 6

Week 17

Week 17. Compare & Contrast Simpson's Puzzle solutions 9 Marks [ ]. This week…. Take a look at a solution to week 15’s Simpson's puzzle. What is good & what is bad? How can we improve on this? Given that Java in a nice OO language Polymorphism

dezso
Download Presentation

Week 17

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Week 17 Compare & Contrast Simpson's Puzzle solutions 9 Marks [ ]

  2. This week…. • Take a look at a solution to week 15’s Simpson's puzzle. • What is good & what is bad? • How can we improve on this? • Given that Java in a nice OO language • Polymorphism • What would a more elegant solution look like?

  3. Remember references? String user_name = new String(“THE”); Pointer to point to string object (called a Reference in Java) Allocate Storage in memory for a String object Connect user_name

  4. Polymorphism! • A very handy OO concept • Any instance of a class which inherits from (extends) another can also be treated as an instance of that class. • Casting is the process of converting an object from one type to another • e.g. converting int to float • Can also be used with object references… • e.g. ((JButton)e.getSource()).setIcon(…)

  5. Casting Object References • In java, any instance is implicitly and transparently casted as necessary. • Provided that the transformation goes upwards the inheritance hierarchy

  6. Inheritance Hierarchies (Casting) Automatic

More Related