To do: October 18
Take out your Dinosaur class worksheet.
Be ready to write on whiteboard.
To do: October 18
Take out your Dinosaur class worksheet.
Write responses to following questions on the whiteboard:
1) When a subclass extends a superclass, which members from the superclass does the subclass inherit?
2) When implementing a constructor of a subclass, what must the first line of the implementation include?
To do: October 18
1) When a subclass extends a superclass, which members from the superclass does the subclass inherit?
2) When implementing a constructor of a subclass, what must the first line of the implementation include?
Homework
Albert's presentation for runtime of Euclidean algorithm
To do:
Compare your Allosaur class implementation with your partner. Then implement class in Repl.it.
Open Monster class in Repl.it
What do you notice about the Monster class that is different from what we've seen so far? List them on whiteboard.
Example of abstract class: Monster class in Repl.it
What is a Concrete class?
A concrete class is one that can be directly created or instantiated, and then used.
In other words, you can create an object from a concrete class definition.
What is an Abstract class?
An abstract class is one where parts of the class are declared abstract, making the whole class abstract.
Those parts of the class that are abstract are incomplete which means that you cannot directly instantiate or create an object using an abstract class.
Example of abstract class: Monster class
What is an advantage of declaring the Monster class abstract?
Abstract classes
Abstract classes are declared abstract and may include:
Abstract class
Now that this class is declared abstract, it is incomplete. Any class that inherits this abstract class is required to complete the implementation of all of the abstract methods.
Summary
When a concrete class definition, one that can be instantiated as an object, reaches a level of complexity where it is too complicated to define within one classβ¦
Itβs time to break it down by using some inheritance techniques, one of which is the use of an abstract class.
To do: Add another class that extends Monster
Homework: