Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computation as an Expressive Medium

Similar presentations


Presentation on theme: "Computation as an Expressive Medium"— Presentation transcript:

1 Computation as an Expressive Medium
Lab 7: Subclasses and Text Capture Jason Alderman

2 Friday! Friday! FRIDAY! Subclass recap [super(); and super.___();]
Text capture recap That's all for now… re•cap == re•ca•pi•tu•late, verb — to cover again, fr. Latin: re again, capit head, ulate ache horribly…of course.

3 Subclass Again, a subclass is like an ordinary class…
…but it potentially has MORE: more fields (if you want to add fields) more methods (if you want to add methods) the same methods (with added functionality) the same methods (completely overwritten) How does it do this, you ask? HOW?

4 The subclass fields By default, the subclass (child) keeps all of the fields of the parent class… …you DON'T have to redeclare them. They're just there! Ready to use! Prêt-a-porter!! If you want to add more fields (variables), just declare them at the top, like you normally would.

5 The subclass constructor
Three ways to do this: Write a whole new constructor, ignoring the constructor of the parent class Write a new constructor that does exactly what the parent class constructor does [using super();] Write a new constructor that does exactly what the parent class constructor does…and then more.

6 The subclass methods …work in much the same way as the constructor.
New method not featured in parent class Overwrite old method with completely new code, ignoring the old code Extend the old method, using super.blah(); (Where blah is the name of the method in the parent class, of course.) and then adding further code Use the old one without changing a thing… UNLIKE the constructor, and LIKE the fields, you don't have to write a line of code, and the methods of the parent class are still there, ready to use!!

7 Keys. As you well know by now, when you type a key, its value is stored in a variable called (drumroll, please) key You can check the value of key anytime, …but this is generally a bad idea! (Like if you're checking the value of key whether a key has been pressed or not, every single time the screen refreshes…? BAD idea!) So, two ways, and two approaches…

8 In this corner… The two ways: The two approaches
if(keyPressed){} in the draw() method void keyPressed() method The two approaches keyPressed will register if the key is pressed (pushed down) keyReleased will register if key has just been released (moves up after being pressed!) (Note: you CANNOT use keyReleased as a boolean…ONLY as a void keyReleased() method.)

9 What about CTRL, ESC, ALT…?
Sometimes there's a key value for these: ESC is 27 …but SHIFT and ALT are both 65535 …and the arrow keys don't register at all! Non-character keys are CODED! if (key == CODED) { … } You have to use the variable keyCode instead of key, e.g., if (keyCode == SHIFT)

10 LOOKIT ME!!1!!! I'M A MICROSOFT CLIP ART!
Recap of the recaps! LOOKIT ME!!1!!! I'M A MICROSOFT CLIP ART! w00t!! We've talked about subclasses (again!) We've talked about keyPressed (again!) Now…more time to work on the assignment If you're reading this after lab, I hope your HCI test went well (again!)


Download ppt "Computation as an Expressive Medium"

Similar presentations


Ads by Google