Tire.frink

Download or view Tire.frink in plain text format


/** This is a class that parses information about a tire maybe using American
    tire specifications.  */

class Tire
{
   var width
   var aspect
   var wheelDiameter
   var construction
   var sidewallHeight
   var tireDiameter

   /** Construct a new tire specification from a string like "265/50 R 20" */
   new[str] :=
   {
      if [usage, width, aspect, construction, wheelDiameter] = str =~ %r/^([A-Z]+)\s*(\d+)\s*\/\s*(\d+)\s*([A-Z]+?)\s*(\d+)/i
      {
         println["matched $str"]
         width = eval[width] mm
         println["width is parsed as $width"]
         aspect = eval[aspect]
         wheelDiameter = eval[wheelDiameter] in
         println["wheel diameter is $wheelDiameter"]
         println["Construction is $construction"]
         sidewallHeight = aspect/100 width
         tireDiameter = wheelDiameter + 2 sidewallHeight
         
      } else
      {
         println["unmatched line $str"]
         
      }
   }
}


Download or view Tire.frink in plain text format


This is a program written in the programming language Frink.
For more information, view the Frink Documentation or see More Sample Frink Programs.

Alan Eliasen was born 20152 days, 21 hours, 40 minutes ago.