SlideShare a Scribd company logo
1 of 23
Object-Oriented Programming Language
                                                   Chapter 7 : More on Classes


                                            Atit Patumvan
                            Faculty of Management and Information Sciences
                                          Naresuan University




วันจันทร์ท่ี 26 มีนาคม 12
2



                            Separate Interface and Implementation files


              Single Source File                                                      Separate Source File
              SourceCode_A.m                                                          SourceCode_A.h


                              Interface Code                                                Interface Code

                                                                                      SourceCode_A.m
                       Implementation Code
                                                                                         Implementation Code

                              Program Code
                                                                                      SourceCode_B.m

                                                                                            Program Code




 Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University                            Object-Oriented Programming Language

วันจันทร์ท่ี 26 มีนาคม 12
3



                            Separate Interface and Implementation files


           Fraction.h

           #import <Foundation/Foundation.h>

           @interface Fraction : NSObject
           :
           @end


           Fraction.m
            #import "Fraction.h"

            @implementation Fraction
            :
            @end

           main.m
           #import <Foundation/Foundation.h>
           #import "Fraction.h"

           int main (int argc, const char * argv[]){ ...
 Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University   Object-Oriented Programming Language

วันจันทร์ท่ี 26 มีนาคม 12
4



                         Separate Interface and Implementation Files

Program 7.1 main.m
01: #import <Foundation/Foundation.h>
02: #import "Fraction.h"
03:
04: int main (int argc, char * argv[])
05: {
06:! NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
07:! Fraction * myFraction = [[Fraction alloc] init];
08:
09:! [myFraction setNumerator: 1];
10:! [myFraction setDenominator: 3];
11:
12:! // display the fraction
13:
14:! NSLog (@"The value of myFraction is:");
15:! [myFraction print];
16:! [myFraction release];
17:
18:! [pool drain];
19:! return 0;
20: }




 Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University   Object-Oriented Programming Language

วันจันทร์ท่ี 26 มีนาคม 12
5



                         Separate Interface and Implementation Files

Program 7.1 Fraction.h

01: #import <Foundation/Foundation.h>
02:
03: // The Fraction class
04:
05: @interface Fraction : NSObject
06: {
07:! int ! numerator;
08:! int ! denominator;
09: }
10:
11: -(void) print;
12: -(void) setNumerator: (int) n;
13: -(void) setDenominator: (int) d;
14: -(int)!numerator;
15: -(int)!denominator;
16: -(double) convertToNum;
17:
18: @end




 Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University   Object-Oriented Programming Language

วันจันทร์ท่ี 26 มีนาคม 12
6



                         Separate Interface and Implementation Files

Program 7.1 Fraction.m
01: #import "Fraction.h"                                                              25: -(double) convertToNum
02:                                                                                   26: {
03: @implementation Fraction                                                          27:! if(denominator != 0)
04:                                                                                   28:! ! return (double) numerator / denominator;
05: -(void) print                                                                     29:! else
06: {                                                                                 30:! ! return NAN;
07:! NSLog(@"%i/%i", numerator, denominator);                                         31: }
08: }                                                                                 32: @end
09: -(void) setNumerator: (int) n
10: {
11:! numerator = n;
12: }
13: -(void) setDenominator: (int) d
14: {
15:! denominator = d;
16: }
17: -(int)!
          numerator
18: {
19:! return numerator;
20: }
21: -(int)!
          denominator
22: {
23:! return denominator;
24: }

 Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University                                 Object-Oriented Programming Language

วันจันทร์ท่ี 26 มีนาคม 12
7



                            Compiling Program from the Command line



       gcc -framwork Foundation Fraction.m main.m -o main



      Using GNUMakefile
        01:      include $(GNUSTEP_MAKEFILES)/common.make
        02:
        03:      TOOL_NAME = main
        04:      main_HEADERS = Fraction.h
        05:      main_OBJC_FILES = main.m Fraction.m
        06:      main_RESOURCE_FILES =
        07:
        08:      include $(GNUSTEP_MAKEFILES)/tool.make




 Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University   Object-Oriented Programming Language

วันจันทร์ท่ี 26 มีนาคม 12
8



                                                    Synthesize Accessor Methods

Program 7.1b Fraction.h                                                               Program 7.1b Fraction.m
01: #import <Foundation/Foundation.h>                                                 01: #import "Fraction.h"
02:                                                                                   02:
03: // The Fraction class                                                             03: @implementation Fraction
04:                                                                                   04:
05: @interface Fraction : NSObject                                                    05: @synthesize numerator, denominator;
06: {                                                                                 06:
07:! int ! numerator;                                                                 07: -(void) print
08:! int ! denominator;                                                               08: {
09: }                                                                                 09:! NSLog(@"%i/%i", numerator, denominator);
10:                                                                                   10: }
11: @property int numerator, denominator;                                             11: -(double) convertToNum
12:                                                                                   12: {
13: -(void) print;                                                                    13:! if(denominator != 0)
14: -(void) convertToNum;                                                             14:! ! return (double) numerator / denominator;
15:                                                                                   15:! else
16: @end                                                                              16:! ! return NAN;
                                                                                      17: }
                                                                                      18: @end




 Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University                                 Object-Oriented Programming Language

วันจันทร์ท่ี 26 มีนาคม 12
9



                               Accessing Properties Using Dot Operator




                                                                                      Dot Operator
       [myFraction numerator]                                                         myFraction.numerator



            instance                         property                                  instance   property


         [myFraction setNumerator: 3]                                                 myFraction.numerator = 3




 Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University                     Object-Oriented Programming Language

วันจันทร์ท่ี 26 มีนาคม 12
10



                               Accessing Properties Using Dot Operator

Program 7.1c main.m
01: #import <Foundation/Foundation.h>
02: #import "Fraction.h"
03:
04: int main (int argc, char * argv[])
05: {
06:! NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
07:! Fraction * myFraction = [[Fraction alloc] init];
08:
09:! //[myFraction setNumerator: 1];
10:! myFraction.numerator = 1;
11:! //[myFraction setDenominator: 3];
12:! myFraction.denominator = 3;
13:! // display the fraction
14:
15:! NSLog (@"The value of myFraction is:");
16:! [myFraction print];
17:! [myFraction release];
18:
19:! [pool drain];
20:! return 0;
21: }




 Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University   Object-Oriented Programming Language

วันจันทร์ท่ี 26 มีนาคม 12
11



                                                    Multiple Argument to Methods


      [myFraction setNumerator: 1];
      [myFraction setDenominator: 3];




      [myFraction setNumerator: 1 andDenominator: 3];




      [myFraction setTo: 1 over: 3];




 Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University   Object-Oriented Programming Language

วันจันทร์ท่ี 26 มีนาคม 12
12



                                                    Multiple Argument to Methods

Program 7.2 Fraction.h
01: #import <Foundation/Foundation.h>
02:
03: // The Fraction class
04:
05: @interface Fraction : NSObject
06: {
07:! int ! numerator;
08:! int ! denominator;
09: }
10:
11: @property int numerator, denominator;
12:
13: -(void) print;
14: -(void) setTo: (int) n over: (int) d;
15: -(double) convertToNum;
16:
17: @end




 Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University   Object-Oriented Programming Language

วันจันทร์ท่ี 26 มีนาคม 12
13



                                                    Multiple Argument to Methods

Program 7.2 Fraction.m                                                                Program 7.2 main.m
01: #import "Fraction.h"                                                              01: import <Foundation/Foundation.h>
02:                                                                                   02: #import "Fraction.h"
03: @implementation Fraction                                                          03:
04:                                                                                   04: int main (int argc, char * argv[])
05: @synthesize numerator, denominator;                                               05: {
06:                                                                                   06:! NSAutoreleasePool * pool =
07: -(void) print                                                                              [[NSAutoreleasePool alloc] init];
08: {                                                                                 07:! Fraction * aFraction =
09:! NSLog(@"%i/%i", numerator, denominator);                                                  [[Fraction alloc] init];
10: }                                                                                 08:
11: -(double) convertToNum                                                            09:! [aFraction setTo: 100 over: 200];
12: {                                                                                 10:! [aFraction print];
13:! if(denominator != 0)                                                             11:
14:! ! return (double) numerator / denominator;                                       12:! [aFraction setTo: 1 over: 3];
15:! else                                                                             13:! [aFraction print];
16:! ! return NAN;                                                                    14:
17: }                                                                                 15:! aFraction.setNumerator= 1;
18: -(void) setTo: (int) n over: (int) d                                              16:! aFraction.setDenominator= 7;
19: {                                                                                 17:! [aFraction print];
20:! numerator = n;                                                                   18:
21:! denominator = d;!                                                                19:! [aFraction release];
22: }                                                                                 20:
23: @end                                                                              21:! [pool drain];
                                                                                      22:! return 0;
                                                                                      23: }
 Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University                             Object-Oriented Programming Language

วันจันทร์ท่ี 26 มีนาคม 12
14



                                                               Operations on Fractions


      _ 4 6
      1 _ _
       + =
      1 4 8
      Program 7.3 Fraction.h
        :
      16: -(void) add: (Fraction * ) f;
        :

      Program 7.3 Fraction.h
        :
      21: -(void) add: (Fraction * ) f
      22: {
      23:! numerator = numerator * f.denominator + denominator                        * f.numerator;
      24:! denominator = denominator * f.denominator;
      25:
      26: }
        :




 Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University                    Object-Oriented Programming Language

วันจันทร์ท่ี 26 มีนาคม 12
15



                                                               Operations on Fractions

Program 7.3 main.m
01: #import <Foundation/Foundation.h>
02: #import "Fraction.h"
03:
04: int main (int argc, char * argv[])
05: {
06:! NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
07:! Fraction * aFraction = [[Fraction alloc] init];
08:! Fraction * bFraction = [[Fraction alloc] init];
09:
10:! [aFraction setTo: 1 over: 4];
11:! [bFraction setTo: 1 over: 2];
12:
13:! [aFraction print];
14:! NSLog(@"+");
15:! [bFraction print];
16:! NSLog(@"=");
17:
18:! [aFraction add: bFraction];
19:! [aFraction print];
20:! [aFraction release];
21:! [bFraction release];
22:
23: ! return 0;
24: }

 Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University      Object-Oriented Programming Language

วันจันทร์ท่ี 26 มีนาคม 12
16



                                                                               Local Variables

      Program 7.4 Fraction.m
        :
      21: -(void) reduce
      22: {
      23:! int u = numerator;
      24:! int v = denominator;
      25:! int temp;
      26:!
      27:! while ( v != 0 ){
      28:! ! temp = u % v;
      29:! ! u = v;
      30:! ! v = temp;
      31:! }
      32:! numerator /= u;
      33:! denominator /= u;
      34: }
        :




 Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University              Object-Oriented Programming Language

วันจันทร์ท่ี 26 มีนาคม 12
17



                                                                               Local Variables

Program 7.4 main.m
01: #import <Foundation/Foundation.h>
02: #import "Fraction.h"
03:
04: int main (int argc, char * argv[])
05: {
06:! NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
07:! Fraction * aFraction = [[Fraction alloc] init];
08:! Fraction * bFraction = [[Fraction alloc] init];
09:
10:! [aFraction setTo: 1 over: 4];
11:! [bFraction setTo: 1 over: 2];
12:
13:! [aFraction print];
14:! NSLog(@"+");
15:! [bFraction print];
16:! NSLog(@"=");
17:
18:! [aFraction add: bFraction];
19:! [aFraction reduce];
20:
21:! [aFraction print];
22:! [aFraction release];
23:! [bFraction release];
24: ! return 0;
25: }
 Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University              Object-Oriented Programming Language

วันจันทร์ท่ี 26 มีนาคม 12
18



                                                                           The self Keyword



      [self reduce;]

      Program 7.4a Fraction.m
        :
      21: -(void) add: (Fraction * ) f
      22: {
      23:! numerator = numerator * f.denominator + denominator                                * f.numerator;
      24:! denominator = denominator * f.denominator;
      25:
      26: [self reduce];
      26: }
        :




 Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University                            Object-Oriented Programming Language

วันจันทร์ท่ี 26 มีนาคม 12
19



                                                                        The static Keyword


       -(int) showPage
       {
         static int pageCount = 0;
         :
         ++pageCount;
         :
         return pageCount;
       }


       #import “Printer.h”
       static int pageCount;

       @implementation Printer
         :
       @end


 Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University          Object-Oriented Programming Language

วันจันทร์ท่ี 26 มีนาคม 12
20



                          Allocating and Return Objects from Methods

       Program 7.5 Fraction.h
        :
      16: -(Fraction) add: (Fraction * ) f;
        :

       Program 7.5 Fraction.h
        :
      21: -(void) add: (Fraction * ) f
      22: {
      23:! numerator = numerator * f.denominator + denominator                        * f.numerator;
      24:! denominator = denominator * f.denominator;
      25:
      26: [self reduce];
      26: }
        :




 Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University                    Object-Oriented Programming Language

วันจันทร์ท่ี 26 มีนาคม 12
21



                          Allocating and Return Objects from Methods

Program 7.5 main.m
01: #import <Foundation/Foundation.h>
02: #import "Fraction.h"
03:
04: int main (int argc, char * argv[])
05: {
06:! NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
07:! Fraction * aFraction = [[Fraction alloc] init];
08:! Fraction * bFraction = [[Fraction alloc] init];
09:
10:! [aFraction setTo: 1 over: 4];
11:! [bFraction setTo: 1 over: 2];
12:
13:! [aFraction print];
14:! NSLog(@"+");
15:! [bFraction print];
16:! NSLog(@"=");
17:
18:! [[aFraction add: bFraction] print];
19:
20:! [aFraction release];
21:! [bFraction release];
22:! [pool drain];
23:! return 0;
24: }

 Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University   Object-Oriented Programming Language

วันจันทร์ท่ี 26 มีนาคม 12
22



                          Allocating and Return Objects from Methods

Program 7.6 main.m
01: #import <Foundation/Foundation.h>
02: #import "Fraction.h"
03:
04: int main (int argc, char * argv[])
05: {
06:! NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
07:! Fraction * aFraction = [[Fraction alloc] init];
08:! Fraction * sum = [[Fraction alloc] init], * sum2;
09:
10:! int i, n, pow2;
11:
12:! [sum setTo: 0 over: 1];
13:
14:! NSLog(@"Enter you value for n:" );
15:! scanf("%i", &n);
16:!
17:! pow2 = 2;
18:! for(i = 1; i<=n; ++i){
19:! ! [aFraction setTo: 1 over: pow2];
20:! ! sum2 = [sum add: aFraction];
21:! ! [sum release];
22:! ! sum = sum2;
23:! ! pow2 *= 2;
24:! }
25:!
 Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University   Object-Oriented Programming Language

วันจันทร์ท่ี 26 มีนาคม 12
23



                          Allocating and Return Objects from Methods

Program 7.6 main.m
26:! NSLog(@"After %i iterations, the sum is %g", n , [sum convertToNum]);
27:
28:! [aFraction release];
29:! [sum release];
30:!
31:! [pool drain];
32:! return 0;
33: }




  2012-03-26 11:07:12.238 main[3496] Enter you value for n:
  5
  2012-03-26 11:07:14.261 main[3496] After 5 iterations, the sum is 0.96875

  2012-03-26 11:14:24.890 main[3672] Enter you value for n:
  10
  2012-03-26 11:14:35.645 main[3672] After 10 iterations, the sum is 0.999023

  2012-03-26 11:14:39.991 main[2184] Enter you value for n:
  15
  2012-03-26 11:14:41.604 main[2184] After 15 iterations, the sum is 0.999969




 Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University   Object-Oriented Programming Language

วันจันทร์ท่ี 26 มีนาคม 12

More Related Content

What's hot

Applicative Logic Meta-Programming as the foundation for Template-based Progr...
Applicative Logic Meta-Programming as the foundation for Template-based Progr...Applicative Logic Meta-Programming as the foundation for Template-based Progr...
Applicative Logic Meta-Programming as the foundation for Template-based Progr...Coen De Roover
 
A recommender system for generalizing and refining code templates
A recommender system for generalizing and refining code templatesA recommender system for generalizing and refining code templates
A recommender system for generalizing and refining code templatesCoen De Roover
 
Modeling Aspects with AP&P Components
Modeling Aspects with AP&P ComponentsModeling Aspects with AP&P Components
Modeling Aspects with AP&P Componentsmukhtarhudaya
 
pointer, structure ,union and intro to file handling
pointer, structure ,union and intro to file handlingpointer, structure ,union and intro to file handling
pointer, structure ,union and intro to file handlingRai University
 
Mca 1 pic u-5 pointer, structure ,union and intro to file handling
Mca 1 pic u-5 pointer, structure ,union and intro to file handlingMca 1 pic u-5 pointer, structure ,union and intro to file handling
Mca 1 pic u-5 pointer, structure ,union and intro to file handlingRai University
 
pointer, structure ,union and intro to file handling
pointer, structure ,union and intro to file handlingpointer, structure ,union and intro to file handling
pointer, structure ,union and intro to file handlingRai University
 
Bsc cs 1 pic u-5 pointer, structure ,union and intro to file handling
Bsc cs 1 pic u-5 pointer, structure ,union and intro to file handlingBsc cs 1 pic u-5 pointer, structure ,union and intro to file handling
Bsc cs 1 pic u-5 pointer, structure ,union and intro to file handlingRai University
 
Diploma ii cfpc- u-5.1 pointer, structure ,union and intro to file handling
Diploma ii  cfpc- u-5.1 pointer, structure ,union and intro to file handlingDiploma ii  cfpc- u-5.1 pointer, structure ,union and intro to file handling
Diploma ii cfpc- u-5.1 pointer, structure ,union and intro to file handlingRai University
 
OpenMI Developers Training
OpenMI Developers TrainingOpenMI Developers Training
OpenMI Developers TrainingJan Gregersen
 
OpenMI Developers Training
OpenMI Developers TrainingOpenMI Developers Training
OpenMI Developers TrainingJan Gregersen
 
Producing simulation sequences by use of a Java-based Framework
Producing simulation sequences by use of a Java-based FrameworkProducing simulation sequences by use of a Java-based Framework
Producing simulation sequences by use of a Java-based FrameworkDaniele Gianni
 
Lecture21 categoriesof userdefinedfunctions.ppt
Lecture21 categoriesof userdefinedfunctions.pptLecture21 categoriesof userdefinedfunctions.ppt
Lecture21 categoriesof userdefinedfunctions.ppteShikshak
 
Data structure week 1
Data structure week 1Data structure week 1
Data structure week 1karmuhtam
 
A Logic Meta-Programming Foundation for Example-Driven Pattern Detection in O...
A Logic Meta-Programming Foundation for Example-Driven Pattern Detection in O...A Logic Meta-Programming Foundation for Example-Driven Pattern Detection in O...
A Logic Meta-Programming Foundation for Example-Driven Pattern Detection in O...Coen De Roover
 
SDE - Dynamic Analysis
SDE - Dynamic AnalysisSDE - Dynamic Analysis
SDE - Dynamic AnalysisJorge Ressia
 
Diving in OOP (Day 1) : Polymorphism and Inheritance (Early Binding/Compile T...
Diving in OOP (Day 1) : Polymorphism and Inheritance (Early Binding/Compile T...Diving in OOP (Day 1) : Polymorphism and Inheritance (Early Binding/Compile T...
Diving in OOP (Day 1) : Polymorphism and Inheritance (Early Binding/Compile T...Akhil Mittal
 

What's hot (20)

Applicative Logic Meta-Programming as the foundation for Template-based Progr...
Applicative Logic Meta-Programming as the foundation for Template-based Progr...Applicative Logic Meta-Programming as the foundation for Template-based Progr...
Applicative Logic Meta-Programming as the foundation for Template-based Progr...
 
A recommender system for generalizing and refining code templates
A recommender system for generalizing and refining code templatesA recommender system for generalizing and refining code templates
A recommender system for generalizing and refining code templates
 
Unit 8
Unit 8Unit 8
Unit 8
 
Modeling Aspects with AP&P Components
Modeling Aspects with AP&P ComponentsModeling Aspects with AP&P Components
Modeling Aspects with AP&P Components
 
Chapter 03 python libraries
Chapter 03 python librariesChapter 03 python libraries
Chapter 03 python libraries
 
pointer, structure ,union and intro to file handling
pointer, structure ,union and intro to file handlingpointer, structure ,union and intro to file handling
pointer, structure ,union and intro to file handling
 
Mca 1 pic u-5 pointer, structure ,union and intro to file handling
Mca 1 pic u-5 pointer, structure ,union and intro to file handlingMca 1 pic u-5 pointer, structure ,union and intro to file handling
Mca 1 pic u-5 pointer, structure ,union and intro to file handling
 
Chapter 02 functions -class xii
Chapter 02   functions -class xiiChapter 02   functions -class xii
Chapter 02 functions -class xii
 
pointer, structure ,union and intro to file handling
pointer, structure ,union and intro to file handlingpointer, structure ,union and intro to file handling
pointer, structure ,union and intro to file handling
 
Bsc cs 1 pic u-5 pointer, structure ,union and intro to file handling
Bsc cs 1 pic u-5 pointer, structure ,union and intro to file handlingBsc cs 1 pic u-5 pointer, structure ,union and intro to file handling
Bsc cs 1 pic u-5 pointer, structure ,union and intro to file handling
 
Diploma ii cfpc- u-5.1 pointer, structure ,union and intro to file handling
Diploma ii  cfpc- u-5.1 pointer, structure ,union and intro to file handlingDiploma ii  cfpc- u-5.1 pointer, structure ,union and intro to file handling
Diploma ii cfpc- u-5.1 pointer, structure ,union and intro to file handling
 
OpenMI Developers Training
OpenMI Developers TrainingOpenMI Developers Training
OpenMI Developers Training
 
OpenMI Developers Training
OpenMI Developers TrainingOpenMI Developers Training
OpenMI Developers Training
 
Producing simulation sequences by use of a Java-based Framework
Producing simulation sequences by use of a Java-based FrameworkProducing simulation sequences by use of a Java-based Framework
Producing simulation sequences by use of a Java-based Framework
 
Lecture21 categoriesof userdefinedfunctions.ppt
Lecture21 categoriesof userdefinedfunctions.pptLecture21 categoriesof userdefinedfunctions.ppt
Lecture21 categoriesof userdefinedfunctions.ppt
 
C Programming - Refresher - Part II
C Programming - Refresher - Part II C Programming - Refresher - Part II
C Programming - Refresher - Part II
 
Data structure week 1
Data structure week 1Data structure week 1
Data structure week 1
 
A Logic Meta-Programming Foundation for Example-Driven Pattern Detection in O...
A Logic Meta-Programming Foundation for Example-Driven Pattern Detection in O...A Logic Meta-Programming Foundation for Example-Driven Pattern Detection in O...
A Logic Meta-Programming Foundation for Example-Driven Pattern Detection in O...
 
SDE - Dynamic Analysis
SDE - Dynamic AnalysisSDE - Dynamic Analysis
SDE - Dynamic Analysis
 
Diving in OOP (Day 1) : Polymorphism and Inheritance (Early Binding/Compile T...
Diving in OOP (Day 1) : Polymorphism and Inheritance (Early Binding/Compile T...Diving in OOP (Day 1) : Polymorphism and Inheritance (Early Binding/Compile T...
Diving in OOP (Day 1) : Polymorphism and Inheritance (Early Binding/Compile T...
 

Similar to OOP Chapter 7 : More on Classes

OOP Chapter 5 : Program Looping
OOP Chapter 5 : Program Looping OOP Chapter 5 : Program Looping
OOP Chapter 5 : Program Looping Atit Patumvan
 
Programming in c++
Programming in c++Programming in c++
Programming in c++MalarMohana
 
Programming in c++
Programming in c++Programming in c++
Programming in c++sujathavvv
 
Open Chemistry: Realizing Open Data, Open Standards, and Open Source
Open Chemistry: Realizing Open Data, Open Standards, and Open SourceOpen Chemistry: Realizing Open Data, Open Standards, and Open Source
Open Chemistry: Realizing Open Data, Open Standards, and Open SourceMarcus Hanwell
 
Principal of objected oriented programming
Principal of objected oriented programming Principal of objected oriented programming
Principal of objected oriented programming Rokonuzzaman Rony
 
The First C# Project Analyzed
The First C# Project AnalyzedThe First C# Project Analyzed
The First C# Project AnalyzedPVS-Studio
 
Introduction to objective c
Introduction to objective cIntroduction to objective c
Introduction to objective cMayank Jalotra
 
Binary code obfuscation through c++ template meta programming
Binary code obfuscation through c++ template meta programmingBinary code obfuscation through c++ template meta programming
Binary code obfuscation through c++ template meta programmingnong_dan
 
From programming to software engineering: ICSE keynote slides available
From programming to software engineering: ICSE keynote slides availableFrom programming to software engineering: ICSE keynote slides available
From programming to software engineering: ICSE keynote slides availableCelso Martins
 
Advances in Parallel Computing for Computational Mechanics. MPI for Python an...
Advances in Parallel Computing for Computational Mechanics. MPI for Python an...Advances in Parallel Computing for Computational Mechanics. MPI for Python an...
Advances in Parallel Computing for Computational Mechanics. MPI for Python an...guest23e06a
 
Introducing Parameter Sensitivity to Dynamic Code-Clone Analysis Methods
Introducing Parameter Sensitivity to Dynamic Code-Clone Analysis MethodsIntroducing Parameter Sensitivity to Dynamic Code-Clone Analysis Methods
Introducing Parameter Sensitivity to Dynamic Code-Clone Analysis MethodsKamiya Toshihiro
 
Software Birthmark for Theft Detection of JavaScript Programs: A Survey
Software Birthmark for Theft Detection of JavaScript Programs: A Survey Software Birthmark for Theft Detection of JavaScript Programs: A Survey
Software Birthmark for Theft Detection of JavaScript Programs: A Survey Swati Patel
 
Programming Without Coding Technology (PWCT) Features - Programming Paradigm
Programming Without Coding Technology (PWCT) Features - Programming ParadigmProgramming Without Coding Technology (PWCT) Features - Programming Paradigm
Programming Without Coding Technology (PWCT) Features - Programming ParadigmMahmoud Samir Fayed
 
(D 15 180770107240)
(D 15 180770107240)(D 15 180770107240)
(D 15 180770107240)RaviModi37
 

Similar to OOP Chapter 7 : More on Classes (20)

OOP Chapter 5 : Program Looping
OOP Chapter 5 : Program Looping OOP Chapter 5 : Program Looping
OOP Chapter 5 : Program Looping
 
Programming in c++
Programming in c++Programming in c++
Programming in c++
 
Programming in c++
Programming in c++Programming in c++
Programming in c++
 
Open Chemistry: Realizing Open Data, Open Standards, and Open Source
Open Chemistry: Realizing Open Data, Open Standards, and Open SourceOpen Chemistry: Realizing Open Data, Open Standards, and Open Source
Open Chemistry: Realizing Open Data, Open Standards, and Open Source
 
Principal of objected oriented programming
Principal of objected oriented programming Principal of objected oriented programming
Principal of objected oriented programming
 
The First C# Project Analyzed
The First C# Project AnalyzedThe First C# Project Analyzed
The First C# Project Analyzed
 
EEDC Programming Models
EEDC Programming ModelsEEDC Programming Models
EEDC Programming Models
 
Opps manual final copy
Opps manual final   copyOpps manual final   copy
Opps manual final copy
 
OOPs manual final copy
OOPs manual final   copyOOPs manual final   copy
OOPs manual final copy
 
Introduction to objective c
Introduction to objective cIntroduction to objective c
Introduction to objective c
 
Binary code obfuscation through c++ template meta programming
Binary code obfuscation through c++ template meta programmingBinary code obfuscation through c++ template meta programming
Binary code obfuscation through c++ template meta programming
 
Report_Internship_TRC Aachen
Report_Internship_TRC AachenReport_Internship_TRC Aachen
Report_Internship_TRC Aachen
 
From programming to software engineering: ICSE keynote slides available
From programming to software engineering: ICSE keynote slides availableFrom programming to software engineering: ICSE keynote slides available
From programming to software engineering: ICSE keynote slides available
 
Advances in Parallel Computing for Computational Mechanics. MPI for Python an...
Advances in Parallel Computing for Computational Mechanics. MPI for Python an...Advances in Parallel Computing for Computational Mechanics. MPI for Python an...
Advances in Parallel Computing for Computational Mechanics. MPI for Python an...
 
Introducing Parameter Sensitivity to Dynamic Code-Clone Analysis Methods
Introducing Parameter Sensitivity to Dynamic Code-Clone Analysis MethodsIntroducing Parameter Sensitivity to Dynamic Code-Clone Analysis Methods
Introducing Parameter Sensitivity to Dynamic Code-Clone Analysis Methods
 
Software Birthmark for Theft Detection of JavaScript Programs: A Survey
Software Birthmark for Theft Detection of JavaScript Programs: A Survey Software Birthmark for Theft Detection of JavaScript Programs: A Survey
Software Birthmark for Theft Detection of JavaScript Programs: A Survey
 
PRELIM-Lesson-2.pdf
PRELIM-Lesson-2.pdfPRELIM-Lesson-2.pdf
PRELIM-Lesson-2.pdf
 
Programming Without Coding Technology (PWCT) Features - Programming Paradigm
Programming Without Coding Technology (PWCT) Features - Programming ParadigmProgramming Without Coding Technology (PWCT) Features - Programming Paradigm
Programming Without Coding Technology (PWCT) Features - Programming Paradigm
 
(D 15 180770107240)
(D 15 180770107240)(D 15 180770107240)
(D 15 180770107240)
 
Lecture 1.pptx
Lecture 1.pptxLecture 1.pptx
Lecture 1.pptx
 

More from Atit Patumvan

Iot for smart agriculture
Iot for smart agricultureIot for smart agriculture
Iot for smart agricultureAtit Patumvan
 
An Overview of eZee Burrp! (Philus Limited)
An Overview of eZee Burrp! (Philus Limited)An Overview of eZee Burrp! (Philus Limited)
An Overview of eZee Burrp! (Philus Limited)Atit Patumvan
 
แบบฝึกหัดวิชา Theory of Computation ชุดที่ 1 เซ็ต
แบบฝึกหัดวิชา Theory of Computation ชุดที่ 1 เซ็ตแบบฝึกหัดวิชา Theory of Computation ชุดที่ 1 เซ็ต
แบบฝึกหัดวิชา Theory of Computation ชุดที่ 1 เซ็ตAtit Patumvan
 
Chapter 1 mathmatics tools
Chapter 1 mathmatics toolsChapter 1 mathmatics tools
Chapter 1 mathmatics toolsAtit Patumvan
 
Chapter 1 mathmatics tools
Chapter 1 mathmatics toolsChapter 1 mathmatics tools
Chapter 1 mathmatics toolsAtit Patumvan
 
รายงานการประเมินคุณภาพภายใน ปีงบประมาณ 2556
รายงานการประเมินคุณภาพภายใน ปีงบประมาณ 2556รายงานการประเมินคุณภาพภายใน ปีงบประมาณ 2556
รายงานการประเมินคุณภาพภายใน ปีงบประมาณ 2556Atit Patumvan
 
Chapter 0 introduction to theory of computation
Chapter 0 introduction to theory of computationChapter 0 introduction to theory of computation
Chapter 0 introduction to theory of computationAtit Patumvan
 
Chapter 01 mathmatics tools (slide)
Chapter 01 mathmatics tools (slide)Chapter 01 mathmatics tools (slide)
Chapter 01 mathmatics tools (slide)Atit Patumvan
 
การบริหารเชิงคุณภาพ ชุดที่ 8
การบริหารเชิงคุณภาพ ชุดที่ 8การบริหารเชิงคุณภาพ ชุดที่ 8
การบริหารเชิงคุณภาพ ชุดที่ 8Atit Patumvan
 
การบริหารเชิงคุณภาพ ชุดที่ 7
การบริหารเชิงคุณภาพ ชุดที่ 7การบริหารเชิงคุณภาพ ชุดที่ 7
การบริหารเชิงคุณภาพ ชุดที่ 7Atit Patumvan
 
การบริหารเชิงคุณภาพ ชุดที่ 6
การบริหารเชิงคุณภาพ ชุดที่ 6การบริหารเชิงคุณภาพ ชุดที่ 6
การบริหารเชิงคุณภาพ ชุดที่ 6Atit Patumvan
 
Computer Programming Chapter 5 : Methods
Computer Programming Chapter 5 : MethodsComputer Programming Chapter 5 : Methods
Computer Programming Chapter 5 : MethodsAtit Patumvan
 
Computer Programming Chapter 4 : Loops
Computer Programming Chapter 4 : Loops Computer Programming Chapter 4 : Loops
Computer Programming Chapter 4 : Loops Atit Patumvan
 
Introduction to Java EE (J2EE)
Introduction to Java EE (J2EE)Introduction to Java EE (J2EE)
Introduction to Java EE (J2EE)Atit Patumvan
 
การบริหารเชิงคุณภาพ ชุดที่ 5
การบริหารเชิงคุณภาพ ชุดที่ 5การบริหารเชิงคุณภาพ ชุดที่ 5
การบริหารเชิงคุณภาพ ชุดที่ 5Atit Patumvan
 
การบริหารเชิงคุณภาพ ชุดที่ 4
การบริหารเชิงคุณภาพ ชุดที่ 4การบริหารเชิงคุณภาพ ชุดที่ 4
การบริหารเชิงคุณภาพ ชุดที่ 4Atit Patumvan
 
การบริหารเชิงคุณภาพ ชุดที่ 3
การบริหารเชิงคุณภาพ ชุดที่ 3การบริหารเชิงคุณภาพ ชุดที่ 3
การบริหารเชิงคุณภาพ ชุดที่ 3Atit Patumvan
 
การบริหารเชิงคุณภาพ ชุดที่ 2
การบริหารเชิงคุณภาพ ชุดที่ 2การบริหารเชิงคุณภาพ ชุดที่ 2
การบริหารเชิงคุณภาพ ชุดที่ 2Atit Patumvan
 
Computer Programming: Chapter 1
Computer Programming: Chapter 1Computer Programming: Chapter 1
Computer Programming: Chapter 1Atit Patumvan
 

More from Atit Patumvan (20)

Iot for smart agriculture
Iot for smart agricultureIot for smart agriculture
Iot for smart agriculture
 
An Overview of eZee Burrp! (Philus Limited)
An Overview of eZee Burrp! (Philus Limited)An Overview of eZee Burrp! (Philus Limited)
An Overview of eZee Burrp! (Philus Limited)
 
แบบฝึกหัดวิชา Theory of Computation ชุดที่ 1 เซ็ต
แบบฝึกหัดวิชา Theory of Computation ชุดที่ 1 เซ็ตแบบฝึกหัดวิชา Theory of Computation ชุดที่ 1 เซ็ต
แบบฝึกหัดวิชา Theory of Computation ชุดที่ 1 เซ็ต
 
Chapter 1 mathmatics tools
Chapter 1 mathmatics toolsChapter 1 mathmatics tools
Chapter 1 mathmatics tools
 
Chapter 1 mathmatics tools
Chapter 1 mathmatics toolsChapter 1 mathmatics tools
Chapter 1 mathmatics tools
 
รายงานการประเมินคุณภาพภายใน ปีงบประมาณ 2556
รายงานการประเมินคุณภาพภายใน ปีงบประมาณ 2556รายงานการประเมินคุณภาพภายใน ปีงบประมาณ 2556
รายงานการประเมินคุณภาพภายใน ปีงบประมาณ 2556
 
Chapter 0 introduction to theory of computation
Chapter 0 introduction to theory of computationChapter 0 introduction to theory of computation
Chapter 0 introduction to theory of computation
 
Media literacy
Media literacyMedia literacy
Media literacy
 
Chapter 01 mathmatics tools (slide)
Chapter 01 mathmatics tools (slide)Chapter 01 mathmatics tools (slide)
Chapter 01 mathmatics tools (slide)
 
การบริหารเชิงคุณภาพ ชุดที่ 8
การบริหารเชิงคุณภาพ ชุดที่ 8การบริหารเชิงคุณภาพ ชุดที่ 8
การบริหารเชิงคุณภาพ ชุดที่ 8
 
การบริหารเชิงคุณภาพ ชุดที่ 7
การบริหารเชิงคุณภาพ ชุดที่ 7การบริหารเชิงคุณภาพ ชุดที่ 7
การบริหารเชิงคุณภาพ ชุดที่ 7
 
การบริหารเชิงคุณภาพ ชุดที่ 6
การบริหารเชิงคุณภาพ ชุดที่ 6การบริหารเชิงคุณภาพ ชุดที่ 6
การบริหารเชิงคุณภาพ ชุดที่ 6
 
Computer Programming Chapter 5 : Methods
Computer Programming Chapter 5 : MethodsComputer Programming Chapter 5 : Methods
Computer Programming Chapter 5 : Methods
 
Computer Programming Chapter 4 : Loops
Computer Programming Chapter 4 : Loops Computer Programming Chapter 4 : Loops
Computer Programming Chapter 4 : Loops
 
Introduction to Java EE (J2EE)
Introduction to Java EE (J2EE)Introduction to Java EE (J2EE)
Introduction to Java EE (J2EE)
 
การบริหารเชิงคุณภาพ ชุดที่ 5
การบริหารเชิงคุณภาพ ชุดที่ 5การบริหารเชิงคุณภาพ ชุดที่ 5
การบริหารเชิงคุณภาพ ชุดที่ 5
 
การบริหารเชิงคุณภาพ ชุดที่ 4
การบริหารเชิงคุณภาพ ชุดที่ 4การบริหารเชิงคุณภาพ ชุดที่ 4
การบริหารเชิงคุณภาพ ชุดที่ 4
 
การบริหารเชิงคุณภาพ ชุดที่ 3
การบริหารเชิงคุณภาพ ชุดที่ 3การบริหารเชิงคุณภาพ ชุดที่ 3
การบริหารเชิงคุณภาพ ชุดที่ 3
 
การบริหารเชิงคุณภาพ ชุดที่ 2
การบริหารเชิงคุณภาพ ชุดที่ 2การบริหารเชิงคุณภาพ ชุดที่ 2
การบริหารเชิงคุณภาพ ชุดที่ 2
 
Computer Programming: Chapter 1
Computer Programming: Chapter 1Computer Programming: Chapter 1
Computer Programming: Chapter 1
 

Recently uploaded

Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupJonathanParaisoCruz
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 

Recently uploaded (20)

Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized Group
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 

OOP Chapter 7 : More on Classes

  • 1. Object-Oriented Programming Language Chapter 7 : More on Classes Atit Patumvan Faculty of Management and Information Sciences Naresuan University วันจันทร์ท่ี 26 มีนาคม 12
  • 2. 2 Separate Interface and Implementation files Single Source File Separate Source File SourceCode_A.m SourceCode_A.h Interface Code Interface Code SourceCode_A.m Implementation Code Implementation Code Program Code SourceCode_B.m Program Code Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University Object-Oriented Programming Language วันจันทร์ท่ี 26 มีนาคม 12
  • 3. 3 Separate Interface and Implementation files Fraction.h #import <Foundation/Foundation.h> @interface Fraction : NSObject : @end Fraction.m #import "Fraction.h" @implementation Fraction : @end main.m #import <Foundation/Foundation.h> #import "Fraction.h" int main (int argc, const char * argv[]){ ... Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University Object-Oriented Programming Language วันจันทร์ท่ี 26 มีนาคม 12
  • 4. 4 Separate Interface and Implementation Files Program 7.1 main.m 01: #import <Foundation/Foundation.h> 02: #import "Fraction.h" 03: 04: int main (int argc, char * argv[]) 05: { 06:! NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; 07:! Fraction * myFraction = [[Fraction alloc] init]; 08: 09:! [myFraction setNumerator: 1]; 10:! [myFraction setDenominator: 3]; 11: 12:! // display the fraction 13: 14:! NSLog (@"The value of myFraction is:"); 15:! [myFraction print]; 16:! [myFraction release]; 17: 18:! [pool drain]; 19:! return 0; 20: } Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University Object-Oriented Programming Language วันจันทร์ท่ี 26 มีนาคม 12
  • 5. 5 Separate Interface and Implementation Files Program 7.1 Fraction.h 01: #import <Foundation/Foundation.h> 02: 03: // The Fraction class 04: 05: @interface Fraction : NSObject 06: { 07:! int ! numerator; 08:! int ! denominator; 09: } 10: 11: -(void) print; 12: -(void) setNumerator: (int) n; 13: -(void) setDenominator: (int) d; 14: -(int)!numerator; 15: -(int)!denominator; 16: -(double) convertToNum; 17: 18: @end Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University Object-Oriented Programming Language วันจันทร์ท่ี 26 มีนาคม 12
  • 6. 6 Separate Interface and Implementation Files Program 7.1 Fraction.m 01: #import "Fraction.h" 25: -(double) convertToNum 02: 26: { 03: @implementation Fraction 27:! if(denominator != 0) 04: 28:! ! return (double) numerator / denominator; 05: -(void) print 29:! else 06: { 30:! ! return NAN; 07:! NSLog(@"%i/%i", numerator, denominator); 31: } 08: } 32: @end 09: -(void) setNumerator: (int) n 10: { 11:! numerator = n; 12: } 13: -(void) setDenominator: (int) d 14: { 15:! denominator = d; 16: } 17: -(int)! numerator 18: { 19:! return numerator; 20: } 21: -(int)! denominator 22: { 23:! return denominator; 24: } Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University Object-Oriented Programming Language วันจันทร์ท่ี 26 มีนาคม 12
  • 7. 7 Compiling Program from the Command line gcc -framwork Foundation Fraction.m main.m -o main Using GNUMakefile 01: include $(GNUSTEP_MAKEFILES)/common.make 02: 03: TOOL_NAME = main 04: main_HEADERS = Fraction.h 05: main_OBJC_FILES = main.m Fraction.m 06: main_RESOURCE_FILES = 07: 08: include $(GNUSTEP_MAKEFILES)/tool.make Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University Object-Oriented Programming Language วันจันทร์ท่ี 26 มีนาคม 12
  • 8. 8 Synthesize Accessor Methods Program 7.1b Fraction.h Program 7.1b Fraction.m 01: #import <Foundation/Foundation.h> 01: #import "Fraction.h" 02: 02: 03: // The Fraction class 03: @implementation Fraction 04: 04: 05: @interface Fraction : NSObject 05: @synthesize numerator, denominator; 06: { 06: 07:! int ! numerator; 07: -(void) print 08:! int ! denominator; 08: { 09: } 09:! NSLog(@"%i/%i", numerator, denominator); 10: 10: } 11: @property int numerator, denominator; 11: -(double) convertToNum 12: 12: { 13: -(void) print; 13:! if(denominator != 0) 14: -(void) convertToNum; 14:! ! return (double) numerator / denominator; 15: 15:! else 16: @end 16:! ! return NAN; 17: } 18: @end Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University Object-Oriented Programming Language วันจันทร์ท่ี 26 มีนาคม 12
  • 9. 9 Accessing Properties Using Dot Operator Dot Operator [myFraction numerator] myFraction.numerator instance property instance property [myFraction setNumerator: 3] myFraction.numerator = 3 Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University Object-Oriented Programming Language วันจันทร์ท่ี 26 มีนาคม 12
  • 10. 10 Accessing Properties Using Dot Operator Program 7.1c main.m 01: #import <Foundation/Foundation.h> 02: #import "Fraction.h" 03: 04: int main (int argc, char * argv[]) 05: { 06:! NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; 07:! Fraction * myFraction = [[Fraction alloc] init]; 08: 09:! //[myFraction setNumerator: 1]; 10:! myFraction.numerator = 1; 11:! //[myFraction setDenominator: 3]; 12:! myFraction.denominator = 3; 13:! // display the fraction 14: 15:! NSLog (@"The value of myFraction is:"); 16:! [myFraction print]; 17:! [myFraction release]; 18: 19:! [pool drain]; 20:! return 0; 21: } Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University Object-Oriented Programming Language วันจันทร์ท่ี 26 มีนาคม 12
  • 11. 11 Multiple Argument to Methods [myFraction setNumerator: 1]; [myFraction setDenominator: 3]; [myFraction setNumerator: 1 andDenominator: 3]; [myFraction setTo: 1 over: 3]; Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University Object-Oriented Programming Language วันจันทร์ท่ี 26 มีนาคม 12
  • 12. 12 Multiple Argument to Methods Program 7.2 Fraction.h 01: #import <Foundation/Foundation.h> 02: 03: // The Fraction class 04: 05: @interface Fraction : NSObject 06: { 07:! int ! numerator; 08:! int ! denominator; 09: } 10: 11: @property int numerator, denominator; 12: 13: -(void) print; 14: -(void) setTo: (int) n over: (int) d; 15: -(double) convertToNum; 16: 17: @end Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University Object-Oriented Programming Language วันจันทร์ท่ี 26 มีนาคม 12
  • 13. 13 Multiple Argument to Methods Program 7.2 Fraction.m Program 7.2 main.m 01: #import "Fraction.h" 01: import <Foundation/Foundation.h> 02: 02: #import "Fraction.h" 03: @implementation Fraction 03: 04: 04: int main (int argc, char * argv[]) 05: @synthesize numerator, denominator; 05: { 06: 06:! NSAutoreleasePool * pool = 07: -(void) print [[NSAutoreleasePool alloc] init]; 08: { 07:! Fraction * aFraction = 09:! NSLog(@"%i/%i", numerator, denominator); [[Fraction alloc] init]; 10: } 08: 11: -(double) convertToNum 09:! [aFraction setTo: 100 over: 200]; 12: { 10:! [aFraction print]; 13:! if(denominator != 0) 11: 14:! ! return (double) numerator / denominator; 12:! [aFraction setTo: 1 over: 3]; 15:! else 13:! [aFraction print]; 16:! ! return NAN; 14: 17: } 15:! aFraction.setNumerator= 1; 18: -(void) setTo: (int) n over: (int) d 16:! aFraction.setDenominator= 7; 19: { 17:! [aFraction print]; 20:! numerator = n; 18: 21:! denominator = d;! 19:! [aFraction release]; 22: } 20: 23: @end 21:! [pool drain]; 22:! return 0; 23: } Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University Object-Oriented Programming Language วันจันทร์ท่ี 26 มีนาคม 12
  • 14. 14 Operations on Fractions _ 4 6 1 _ _ + = 1 4 8 Program 7.3 Fraction.h : 16: -(void) add: (Fraction * ) f; : Program 7.3 Fraction.h : 21: -(void) add: (Fraction * ) f 22: { 23:! numerator = numerator * f.denominator + denominator * f.numerator; 24:! denominator = denominator * f.denominator; 25: 26: } : Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University Object-Oriented Programming Language วันจันทร์ท่ี 26 มีนาคม 12
  • 15. 15 Operations on Fractions Program 7.3 main.m 01: #import <Foundation/Foundation.h> 02: #import "Fraction.h" 03: 04: int main (int argc, char * argv[]) 05: { 06:! NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; 07:! Fraction * aFraction = [[Fraction alloc] init]; 08:! Fraction * bFraction = [[Fraction alloc] init]; 09: 10:! [aFraction setTo: 1 over: 4]; 11:! [bFraction setTo: 1 over: 2]; 12: 13:! [aFraction print]; 14:! NSLog(@"+"); 15:! [bFraction print]; 16:! NSLog(@"="); 17: 18:! [aFraction add: bFraction]; 19:! [aFraction print]; 20:! [aFraction release]; 21:! [bFraction release]; 22: 23: ! return 0; 24: } Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University Object-Oriented Programming Language วันจันทร์ท่ี 26 มีนาคม 12
  • 16. 16 Local Variables Program 7.4 Fraction.m : 21: -(void) reduce 22: { 23:! int u = numerator; 24:! int v = denominator; 25:! int temp; 26:! 27:! while ( v != 0 ){ 28:! ! temp = u % v; 29:! ! u = v; 30:! ! v = temp; 31:! } 32:! numerator /= u; 33:! denominator /= u; 34: } : Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University Object-Oriented Programming Language วันจันทร์ท่ี 26 มีนาคม 12
  • 17. 17 Local Variables Program 7.4 main.m 01: #import <Foundation/Foundation.h> 02: #import "Fraction.h" 03: 04: int main (int argc, char * argv[]) 05: { 06:! NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; 07:! Fraction * aFraction = [[Fraction alloc] init]; 08:! Fraction * bFraction = [[Fraction alloc] init]; 09: 10:! [aFraction setTo: 1 over: 4]; 11:! [bFraction setTo: 1 over: 2]; 12: 13:! [aFraction print]; 14:! NSLog(@"+"); 15:! [bFraction print]; 16:! NSLog(@"="); 17: 18:! [aFraction add: bFraction]; 19:! [aFraction reduce]; 20: 21:! [aFraction print]; 22:! [aFraction release]; 23:! [bFraction release]; 24: ! return 0; 25: } Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University Object-Oriented Programming Language วันจันทร์ท่ี 26 มีนาคม 12
  • 18. 18 The self Keyword [self reduce;] Program 7.4a Fraction.m : 21: -(void) add: (Fraction * ) f 22: { 23:! numerator = numerator * f.denominator + denominator * f.numerator; 24:! denominator = denominator * f.denominator; 25: 26: [self reduce]; 26: } : Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University Object-Oriented Programming Language วันจันทร์ท่ี 26 มีนาคม 12
  • 19. 19 The static Keyword -(int) showPage { static int pageCount = 0; : ++pageCount; : return pageCount; } #import “Printer.h” static int pageCount; @implementation Printer : @end Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University Object-Oriented Programming Language วันจันทร์ท่ี 26 มีนาคม 12
  • 20. 20 Allocating and Return Objects from Methods Program 7.5 Fraction.h : 16: -(Fraction) add: (Fraction * ) f; : Program 7.5 Fraction.h : 21: -(void) add: (Fraction * ) f 22: { 23:! numerator = numerator * f.denominator + denominator * f.numerator; 24:! denominator = denominator * f.denominator; 25: 26: [self reduce]; 26: } : Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University Object-Oriented Programming Language วันจันทร์ท่ี 26 มีนาคม 12
  • 21. 21 Allocating and Return Objects from Methods Program 7.5 main.m 01: #import <Foundation/Foundation.h> 02: #import "Fraction.h" 03: 04: int main (int argc, char * argv[]) 05: { 06:! NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; 07:! Fraction * aFraction = [[Fraction alloc] init]; 08:! Fraction * bFraction = [[Fraction alloc] init]; 09: 10:! [aFraction setTo: 1 over: 4]; 11:! [bFraction setTo: 1 over: 2]; 12: 13:! [aFraction print]; 14:! NSLog(@"+"); 15:! [bFraction print]; 16:! NSLog(@"="); 17: 18:! [[aFraction add: bFraction] print]; 19: 20:! [aFraction release]; 21:! [bFraction release]; 22:! [pool drain]; 23:! return 0; 24: } Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University Object-Oriented Programming Language วันจันทร์ท่ี 26 มีนาคม 12
  • 22. 22 Allocating and Return Objects from Methods Program 7.6 main.m 01: #import <Foundation/Foundation.h> 02: #import "Fraction.h" 03: 04: int main (int argc, char * argv[]) 05: { 06:! NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; 07:! Fraction * aFraction = [[Fraction alloc] init]; 08:! Fraction * sum = [[Fraction alloc] init], * sum2; 09: 10:! int i, n, pow2; 11: 12:! [sum setTo: 0 over: 1]; 13: 14:! NSLog(@"Enter you value for n:" ); 15:! scanf("%i", &n); 16:! 17:! pow2 = 2; 18:! for(i = 1; i<=n; ++i){ 19:! ! [aFraction setTo: 1 over: pow2]; 20:! ! sum2 = [sum add: aFraction]; 21:! ! [sum release]; 22:! ! sum = sum2; 23:! ! pow2 *= 2; 24:! } 25:! Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University Object-Oriented Programming Language วันจันทร์ท่ี 26 มีนาคม 12
  • 23. 23 Allocating and Return Objects from Methods Program 7.6 main.m 26:! NSLog(@"After %i iterations, the sum is %g", n , [sum convertToNum]); 27: 28:! [aFraction release]; 29:! [sum release]; 30:! 31:! [pool drain]; 32:! return 0; 33: } 2012-03-26 11:07:12.238 main[3496] Enter you value for n: 5 2012-03-26 11:07:14.261 main[3496] After 5 iterations, the sum is 0.96875 2012-03-26 11:14:24.890 main[3672] Enter you value for n: 10 2012-03-26 11:14:35.645 main[3672] After 10 iterations, the sum is 0.999023 2012-03-26 11:14:39.991 main[2184] Enter you value for n: 15 2012-03-26 11:14:41.604 main[2184] After 15 iterations, the sum is 0.999969 Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University Object-Oriented Programming Language วันจันทร์ท่ี 26 มีนาคม 12