daily pastebin goal
29%
SHARE
TWEET

Untitled

a guest Jan 23rd, 2019 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //adapted from the book "Practical Object-Oriented Design in Ruby" by Sandi Metz
  2.  
  3. namespace GetterSetterExample
  4. {
  5.     public class Gear
  6.     {
  7.         private int chainring, cog, rim; //instance data fields
  8.         private double tire;
  9.        
  10.         public Gear (int chainring, int cog, int rim, double tire) //constructor
  11.         {
  12.             this.chainring = chainring;
  13.             this.cog = cog;
  14.             this.rim = rim;
  15.             this.tire = tire;
  16.         }
  17.  
  18.         public int GetChainringSize () //accessor (aka getter) for chainring
  19.         {
  20.             return this.chainring;
  21.         }
  22.  
  23.         public void SetChainringSize (int chainringSize) //mutator (aka setter) for chainring
  24.         {
  25.             this.chainring = chainringSize;
  26.         }
  27.  
  28.         public int GetCogSize () //accessor/getter for cog
  29.         {
  30.             return this.cog;
  31.         }
  32.  
  33.         public void SetCogSize (int cogSize) //mutator/setter for cog
  34.         {
  35.             this.cog = cogSize;
  36.         }
  37.  
  38.         public int GetRimSize () //accessor/getter for rim
  39.         {
  40.             return this.rim;
  41.         }
  42.  
  43.         public void SetRimSize (int rimSize) //mutator/setter for rim
  44.         {
  45.             this.rim = rimSize;
  46.         }
  47.  
  48.         public double GetTireSize () //accessor/getter for tire
  49.         {
  50.             return this.tire;
  51.         }
  52.  
  53.         public void SetTireSize (double tireSize) //mutator/setter for tire
  54.         {
  55.             this.tire = tireSize;
  56.         }
  57.     }    
  58. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top