Advertisement
emsiardy

DoomsApp

Mar 29th, 2015
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.95 KB | None | 0 0
  1. using System;
  2. //Dev: Dooms
  3.  
  4. namespace ShippingChargesApp
  5. {
  6.     class ShippingChargesClass
  7.     {
  8.         //Declare Datafields
  9.         private int qty;
  10.         private double aValue;
  11.         private string total;
  12.  
  13.         //Constructors
  14.  
  15.         //default
  16.         public ShippingChargesClass()
  17.         {
  18.         }
  19.  
  20.         //constructor with 3 args
  21.         public ShippingChargesClass(int theQty, double theValue, string theTotal)
  22.         {
  23.             theQty = qty;
  24.             theValue = aValue;
  25.             theTotal = total;
  26.         }
  27.  
  28.         //Properties
  29.         public int Qty
  30.         {
  31.             get { return qty; }
  32.             set { qty = value; }
  33.         }
  34.  
  35.         public double Value
  36.         {
  37.             get { return aValue; }
  38.             set { aValue = value; }
  39.         }
  40.         public string Total
  41.         {
  42.             get { return total; }
  43.             set { total = value; }
  44.         }
  45.  
  46.         public double DetermineTotal(int theQty, double theValue, string theTotal)
  47.         {
  48.             if(theQty == 1) // if only 1 item
  49.             {
  50.                 theValue = 2.99; // cost of the 1 item
  51.             }
  52.             else if (theQty > 1 && theQty < 6) // Cost of items from 2 to 5
  53.             { theValue = (2.99 + (theQty - 1) * (1.99)); }
  54.                 else if(theQty > 5 && theQty < 15) // cost of items from 6 to 14
  55.                     {
  56.                         theValue = (2.99 + (theQty - 5) * (1.49) + 10.95);
  57.                     }
  58.                     else if(theQty > 14) // cost of items anywhere after 14
  59.                     {
  60.                         theValue = (2.99 + (theQty - 14) * (0.99) + 24.36);
  61.                     }
  62.  
  63.  
  64.             return theValue;
  65.         }
  66.  
  67.         public override string ToString()
  68.         {
  69.             return "\tShipping Charges App" +
  70.                     "\n\nQty: " + qty +
  71.                     "\nShipping Cost: " + DetermineTotal();
  72.         }
  73.  
  74.     }
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement