Object Oriented Programming
- Classes- Everything you work with in programming, such as forms, buttons, images, labels, etc.
- Object- is an instance of a class, such as 1 button, 1 animal, 1 car, etc. You actually create and manipulate objects when programming.
- Method- Is the behavior of an object, such as a blue form, an enabled button, a moving turtle, etc. Methods can be called subroutines or event methods. Methods can be public or private.
- Superclass- a main class that you base other classes off of. For instance, you have an animal class, and then make a turtle class from it. So, the turtle is considered a subclass.
- Inheritance- this is when 1 class, like a subclass, , receives methods and properties from its superclass. 'extends' in java. ' : ' in C#
- Java; Turtle extends Animal
- C# Turtle: Animal
- If statements- a way to provide conditional logic in programming.
- ( ) equals perimeters
- perimeter could be x and y
- if statements do not end with a ' ; ' they start with if then put what to do in parenthesis
- METHODS ARE ALWAYS IN PARENTHESIS
- METHODS ARE ALWAYS IN PARENTHESIS
- METHODS ARE ALWAYS IN PARENTHESIS
- METHODS ARE ALWAYS IN PARENTHESIS
- METHODS ARE ALWAYS IN PARENTHESIS
- METHODS ARE ALWAYS IN PARENTHESIS
- METHODS ARE ALWAYS IN PARENTHESIS
- METHODS ARE ALWAYS IN PARENTHESIS
- METHODS ARE ALWAYS IN PARENTHESIS
- CamelCase is in the method
- Compiler does not care about empty spaces
- type single instruction-breaking methods inside of method
- _______________________________________________
- Inheritance means? uses extends or :
- Superclass/Subclass know the difference
- negative(left) positive(right)
- dit notation. before the . is a class like "Greenfoot."
- Classes are capitalized
- know camelCase
- inside parenthesis is parameter
- /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
- one = is an assignment operator
- = = is equality
- objects can talk to other objects
- to create a new object in the class, the key word is new
- An object is simply an instance of a class
- Local Variable
- A constructor is a special method that gets called automatically when an abject is created. So, when the whole is created, this constructor is auto created or executed. A constructor is similar to a normal method but with a few exceptions...
- 1- the name is always the same as the name of the class
- 2- repeat- the name is ALWAYS THE SAME AS THE CLASS.
- 3- A constructor has no return value, like void or some data type.
- Constructors never return anything
- Every class in Java has a default constructor, and if you don't write it, then the java system will give you a constructor, which is simple and looks like public Ball()
- the default constructor will ALWAYS have these things:
- Public
- named with the SAME NAME as the class, such as Ball
- and have NO method OR parameters, just a { }
- Writing no constructor is exactly the same as writing this constructor
- 2 Things happen when you play the world...
- 1) a new ball object is created, using the addObject(new Ball(),...)
- 2) The constructor for the object gets "executed" in the object's class
- Note: parameter lists must match between the world and the object's class
- speaking of parameters...how can we add them and make them match?
- static means that it's pertaining to the system or the default environment
- field stores the state of the object, or some info about the current object.
- the info we want to store is which ball we're currently using
- typically, to make hospitable code, you ctart this near the top