Download presentation
Presentation is loading. Please wait.
Published byNorman Hardy Modified over 9 years ago
1
Object Oriented Programming Criteria: P2 Date: 07/10/15 Name: Thomas Jazwinski
2
Tools – Predefined Methods P2 Predefined methods are methods that have already been written by a developer of the programming language and can be used by anyone as many times as they like. These predefined functions are found in the library of that programming language. The library of the Java programming language is slightly more complicated as it has classes inside the library which has the predefined function in there.
3
Tools – Predefined Methods This shows an example of where I have used a predefined method in object oriented program I created. This predefined functions calculate the square root of a number and as you can see from the second screenshot, it is taken from the java.lang.Math class in the java library P2
4
Tools – Screen Design When using object-oriented programming you can create screen designs by using tools which are objects of the program. For example using Visual C# you can drag and drop tools onto a form to design the way you would like it to look. These tools include buttons, text boxes, check boxes ect. P2
5
Using Integrated Development Environment’s An integrated development environment (IDE) is a piece of software that helps a programmer to produce a program. It does this by helping the programmer in many ways to make writing code much easier. Examples of IDE’s which support object oriented programming is Code Blocks, Eclipse and BlueJ. All of these IDE’s help the user to create a program in various different ways but also have similar features for example a compiler to compile the code so it can be executed, and a debugger which identifies any bugs or errors in a program. It also helps with colour coding different parts of the code and most IDE’s also have some code completion which finishes the names of variables and methods so that you don’t have to type the whole thing. P2
6
Eclipse and Code Blocks have a similar interface as they both show only the source code for the program. BlueJ is slightly better for getting used to object oriented programming as it shows the classes and the objects in a much easier way to understand. It also shows the methods that are available to be called by that function. This shows and example a program I have written using the Blue J IDE: Using Integrated Development Environment’s Classes Objects Methods P2
7
Global Variables Global variables in object oriented programming are variables that have a global scope. This means that they can be used in any method within a class and the value stored in the variable can be changed any time it is used. An example of a global variable I have used is shown on the right. As you can see, the ‘totalNum’ variable is declared outside of the methods and is used in multiple different methods within the program. P2
8
Local Variables Local variables are variables which are declared within a method and only have a local scope. This means that the variable can only be used within the method in which it was declared unlike a global variable which can be used by any method. The screenshot on the right shows an example of where I have used a local variable called ‘venueFull’ in a program I created: P2
9
Static Variables A static variable is the same as a class variable that is declared in the class and its value is shared with every instance object made from that class and is declared using the word ‘static’. As you can see below I have created a static variable in my clicker program which increments every time a new clicker object is created. You can see that the class has had 3 clicker objects created from it. P2
10
Method Overloading Method overloading is an object oriented programing feature which allows a class to have more than one method with the same name. This can only be done if the arguments for the methods are different for example if they have parameters with different data types or a different number of parameters As you can see in the example I have created below, the methods have the same name but it is not a problem as they have a different number of parameters P2
11
Instance In object oriented programming, an object is an instance of a class. This means that all of the objects in a class are different instances of the same class which is used like the blue prints for an object. An example of this is shown below there are 2 clicker objects from the same class, but they are separate because they are 2 different instances of the clicker class as you can see as they have different values inside them. P2
12
Example of Object Oriented Program This is the full Clicker program which I created using Blue J IDE which I have used as examples throughout the powerpoint:
13
Example of Object Oriented Program
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.