Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- //Dev: Dooms
- namespace ShippingChargesApp
- {
- class ShippingChargesClass
- {
- //Declare Datafields
- private int qty;
- private double aValue;
- private string total;
- //Constructors
- //default
- public ShippingChargesClass()
- {
- }
- //constructor with 3 args
- public ShippingChargesClass(int theQty, double theValue, string theTotal)
- {
- theQty = qty;
- theValue = aValue;
- theTotal = total;
- }
- //Properties
- public int Qty
- {
- get { return qty; }
- set { qty = value; }
- }
- public double Value
- {
- get { return aValue; }
- set { aValue = value; }
- }
- public string Total
- {
- get { return total; }
- set { total = value; }
- }
- public double DetermineTotal(int theQty, double theValue, string theTotal)
- {
- if(theQty == 1) // if only 1 item
- {
- theValue = 2.99; // cost of the 1 item
- }
- else if (theQty > 1 && theQty < 6) // Cost of items from 2 to 5
- { theValue = (2.99 + (theQty - 1) * (1.99)); }
- else if(theQty > 5 && theQty < 15) // cost of items from 6 to 14
- {
- theValue = (2.99 + (theQty - 5) * (1.49) + 10.95);
- }
- else if(theQty > 14) // cost of items anywhere after 14
- {
- theValue = (2.99 + (theQty - 14) * (0.99) + 24.36);
- }
- return theValue;
- }
- public override string ToString()
- {
- return "\tShipping Charges App" +
- "\n\nQty: " + qty +
- "\nShipping Cost: " + DetermineTotal();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement