Converting Prosedural Style to OOP Taste

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
gurujoni
Forum Newbie
Posts: 2
Joined: Mon Mar 16, 2009 1:04 am

Converting Prosedural Style to OOP Taste

Post 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.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Converting Prosedural Style to OOP Taste

Post by requinix »

That's not object-oriented programming. What are you trying to do?
gurujoni
Forum Newbie
Posts: 2
Joined: Mon Mar 16, 2009 1:04 am

Re: Converting Prosedural Style to OOP Taste

Post 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
Post Reply