Note to Couprie: A new lesson is needed on using Packages to organize the project.
CSE3120: Object Oriented Programming Credit Timeline
Evaluation of the OOP Credit
Knowledge of Theory and Terminology                                        10%
- including UML Class Diagrams
Demonstration of Base level skills                                         50%
- Solving prescriptive problems
- Applying Object Oriented Programming to solve basic problems (usually using one main class and one extra class)
Demonstration of Advanced skills include                                20%
- Using ArrayLists to store instances
- Applying OOP to solve complex problems (using many classes)
- Using arrays or arraylists as member variables
- Inheritance
- Optional: Integrating OOP into GUI based programs
Java Final Project - including most of  OOP, Searching, Sorting and files        20%
Part 1: Introductory Concepts
Lesson - What is object oriented programming (aka OOP)? Â It is all about creating blueprints for something and then creating copies based on those blueprints. Â
- Example1: Ford creates a blueprint for making their next car. Â They then can make multiple instances (thousands) of cars based on that blueprint. Â These cars can each have their own colour and they can all be used in different ways (but these ways all share similar driving behaviours). Â
- Example 2: Now, think of scanning for user input. Â You create a numscan and a wordscan. Â These are two instances of a Scanner object. Â The blueprint is a java class called Scanner and in that blue print are a series of methods such as nextInt( ) and nextLine( ).
- Example 3: In Game Maker, you set up objects.  Each object has a set of events and actions.  These events are akin to java methods and we call them behaviours in java speak.  Next, consider that the object does not actually exist until you put it into a room.  This is called creating an instance of that object.  Each instance has a set of variables (x position, speed, direction, etc).  The variables of each instance are called its state.
Lesson - Complete OOP Activity 0.1Â Â It is a reading activity. Â Be sure to read carefully as it creates a fundamental base for all future activities.
Lesson - Types of Classes
- There are 4 types of classes that we will be working with:
- Main class - contains the main method that drives the whole program, or at least starts it.
- Data class - This holds only data and has very few methods (used only to access that data). Â For example, an instance of a Student class would hold all the information about that one student. Â
- Methods only class - This contains only methods and you can use this class without creating an instance of it. Â
- Combination of Data and Methods - This is the most common type of OOP class and we will spend most of our time working on it.
- If you are taking this in block 5, you missed two important examples that begin with Methods Only classes. Â See your teacher for examples using the Input and Randomize classes.
- If you want a good example of Methods Only classes, watch the following videos but be aware that they assume you do not even know what a method is so they start simple
Marked Activity:Â OOP 1 - Methods Only Class
Learning Activity:
- Read through chapter 25 and 26 on the following webpage. Â
- After completing each chapter, complete the quiz link.
- Email your teacher the mark you got on the quiz and the questions you got incorrect. Â This mark will be formative only.
- Complete this assignment
Lesson: TheNewBoston.com videos
Tutorial 16 - Many Methods and Instances
Tutorial 17 - Constructors
Marked Activity: OOP 2Â -Coins
Marked Activity: OOP3 - Bank Account
Marked Activity:Â Â OOP Activity 4 -Â Theory of OOP
Part 2: Encapsulation using Private and Public
Major Lesson: Private and public variables and methods and other concepts
- One of the key benefits of OOP is something called Encapsulation. Â This means that data within a class is completely protected from the outside world and only certain methods can access this data. Â Both variables and methods can be protected. Â There are 3 levels of protection:
- Private - can only be accessed from within the current class.
- Example - in a banking system, you would ONLY want the deposit and withdrawal methods to be able to change the balance. Â Therefore the balance should be private.
- Public - can be accessed from the MAIN method or any other class for that matter
- Protected - works with ‘packages’ which we have not dealt with
- Learning Activities: Watch TheNewBoston.com videos #36-41 (Do only 38, 39 if short of time)
- Optional: complete the code as you watch the videos
Marked Activity: Â OOP 5 Geometry
Part 3: UML for Planning Classes
Lesson: Using UML to plan your files
- UML is a common method for planning your classes. Â It uses a simple chart for each class:
Class Name |
| Clients |
Variables + or - variable name: variable type
|
| + name:String + age: int  -matched: boolean |
Methods + or -methodname(parameters if any): return type |
| + goodMatch(int a,String )g: boolean + printInfo(): void |
- Most future assignments will ask you to create a diagram such as this one for each assignment. Â
- This particular picture is not the best
- Once you learn about Private and public, you will understand what the + (public) and - (private) signs are for.
Marked Activity: OOP Activity 5 - Geometry
- Requires that you already know about Private and Public variables plus how to use multiple constructors within a class. Â If you need help with either of these concepts, come see me.
Marked NO HELP Activity: OOP 6 - Database
- This assignment is to serve as a test of your knowledge gained so far. Â You may ask for occasional advice from other students and the teacher but it should be primarily your own work.
Part 5: Inheritance and Other Advanced Concepts
Lesson: Static and Final
- Watch thenewboston YouTube Videos: 46-48 Static and Final
Lesson - One of the key benefits of using OOP is the ability to create subclasses.  Subclasses inherit all the variables and  methods of the parent class.  However, they can include additional methods and override the methods of the parent class.  (They can also include new instance variables but the example below does not bother with this.)  For example:
- Parent Class: Dog - Contains state variables such as height, colour, etc. and methods such as wagTail( ), eat( ), run ( ), etc.
- Subclass: WeinerDog - contains all the same as above, however, because it is so low to the ground it has its own run method that helps it avoid small objects sticking out of the ground.  This run( ) method will override the normal run( ) in the parent class.  In java, we say that WeinerDog extends Dog to indicate that it is a subclass of dog
- Subclass: SaintBernardDog - contains all the regular variables and methods but includes a new method called SaveStrandedMountainClimber( ) that rescues lost travellers and delivers them rum.
Lesson - Read the following two webpages:
- What is Inheritance - this one is short, read the whole thing
- Inheritance Coding Example - read this.  Pay close attention to the constructor method for the MatchBox class (the word Super is used to indicate that you will use the box class’ constructor but add one additional variable)
Optional Lesson (if you need more on Inheritance)
- Watch TheNewBoston Video #49 Inheritance.  Access the videos by clicking here.
Marked Activity - OOP 8Â Inheritance Assignment:
Part 6: Putting It All Together
Marked Activity - OOP 9 Using a Text File
Preparing for the exam - here are the terms and practice activities