Page 1 of 1

Converting Prosedural Style to OOP Taste

Posted: Mon Mar 16, 2009 1:13 am
by gurujoni
i am learning in OOP code, but seem like a little "stucked" when trying to converting function based on prosedural to OOP taste, i hope someone who have more experienced than us can help me out to make some solution :

Code: Select all

 
    
if ($in1!='' or $jur1!='' or $thn1!='') 
      { 
      CekKolom3($in1,$jur1,$thn1,$inf3); // the code for the function is on another page but it's worked
      $A1=true; 
      } 
       
          
   switch ($A1) { 
         case 1: 
            if($in2!='' and $jur2 !="" and $thn2 !="") { 
            $A2=true; } 
            elseif ($in2!='' or $jur2 !="" or $thn2 !="") { exit ("the second Data is not Complete yet"); } 
         break; 
         case 0: 
            if($in2!='' or $jur2 !="" or $thn2 !="") 
            { exit ("Data pertama belum terisi");} 
         break; }    
 
   switch ($A2) {   //this variabel taking from the above switch. 
         case 1: 
            if($in3!='' and $jur3 !="" and $thn3 !="") { 
            $A3=true; } 
            elseif ($in3!='' or $jur3 !="" or $thn3 !="") { exit ("the second Data is not Complete yet"); } 
         break; 
         case 0: 
            if($in3!='' or $jur3 !="" or $thn3 !="") 
            { exit ("Data Kedua belum terisi");} 
         break; }       
 
 
for me it's kinda hard to be implemented due to the second switch line is taking variable from the first switch line ($A2), what a mess for a beginner like me.....

thx for the reply and hoping this will help other person who got stuck on OOP implementation....

Thank for reply one again....

this code can be run in prosedural style
Life Isn't easy as it Thought but some help out there never gone.

Re: Converting Prosedural Style to OOP Taste

Posted: Mon Mar 16, 2009 1:23 am
by requinix
That's not object-oriented programming. What are you trying to do?

Re: Converting Prosedural Style to OOP Taste

Posted: Mon Mar 16, 2009 1:31 am
by gurujoni
that's right its prosedural thing, but i curious how to convert my prosedural script into OOP since that script using many on my other logic.

if you have some advice on, how to convert it, i really thankfull btw, thx for reply