Changes between Version 1 and Version 2 of QuickStart/2:ModellingourApplication

Show
Ignore:
Timestamp:
04/27/09 14:26:59 (17 years ago)
Author:
cfgrok (IP: 64.30.223.5)
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • QuickStart/2:ModellingourApplication

    v1 v2  
    1111 
    1212<cffunction name="init" returntype="any" access="public" output="false"> 
     13        <cfargument name="vowels" type="string" required="true" /> 
    1314 
    14 <cfargument name="vowels" type="string" required="true" /> 
     15        <cfset variables.vowels = arguments.vowels /> 
    1516 
    16 <cfset variables.vowels = arguments.vowels /> 
    17  
    18 <cfreturn this /> 
    19  
     17        <cfreturn this /> 
    2018</cffunction> 
    2119 
    2220<cffunction name="translate" returntype="string" access="public" output="false"> 
     21        <cfargument name="phrase" /> 
    2322 
    24 <cfargument name="phrase" /> 
     23        <cfset var firstVowel = reFindNoCase("[#variables.vowels#]", arguments.phrase) - 1/> 
     24        <cfset var result = trim(arguments.phrase) /> 
    2525 
    26 <cfset var firstVowel = reFindNoCase("[#variables.vowels#]", arguments.phrase) - 1/> 
     26        <!--- We started with a consonant ---> 
     27        <cfif len(result) and firstVowel gt 0> 
     28                <cfset result = right(arguments.phrase, len(arguments.phrase) - firstVowel) 
     29                        & left(arguments.phrase, firstVowel) & "ay" /> 
     30        <!--- We started with a vowel ---> 
     31        <cfelseif len(result)> 
     32                <cfset result = result & "ay" /> 
     33        </cfif> 
    2734 
    28 <cfset var result = trim(arguments.phrase) /> 
    29  
    30 <!--- We started with a consonant ---> 
    31  
    32 <cfif len(result) and firstVowel gt 0> 
    33  
    34 <cfset result = right(arguments.phrase, len(arguments.phrase) - firstVowel) & left(arguments.phrase, firstVowel) & "ay" /> 
    35  
    36 <!--- We started with a vowel ---> 
    37  
    38 <cfelseif len(result)> 
    39  
    40 <cfset result = result & "ay" /> 
    41  
    42 </cfif> 
    43  
    44 <cfreturn result /> 
    45  
     35        <cfreturn result /> 
    4636</cffunction> 
    4737