Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace applicationName
- {
- public class Customer
- {
- // Members
- private int id;
- private string name;
- //private string lName;
- private string address;
- // private string regionID;
- private string email;
- private double phone;
- private DateTime addDate;
- private int totalTransactions;
- // Constructors
- public Customer()
- {
- id = 159256;
- name = "Jimmy Dean";
- address = "117 Road Lane";
- // regionID = "SW";
- email = "jim@gmail.com";
- phone = 2053335555;
- addDate = DateTime.Today;
- totalTransactions = 200;
- }
- public Customer(int newId, string newName, string newAddress, string newEmail, double newPhone, DateTime newDate, int newTotalTransactions)
- {
- id = newId;
- name = newName;
- address = newAddress;
- //regionID = newregionID;
- email = newEmail;
- phone = newPhone;
- addDate = newDate;
- totalTransactions = newTotalTransactions;
- }
- //Properties
- public int Id
- {
- get { return id; }
- set { id = value; }
- }
- public string Name
- {
- get { return name; }
- set { name = value; }
- }
- public string Address
- {
- get { return address; }
- set { address = value; }
- }
- public string Email
- {
- get { return email; }
- set { email = value; }
- }
- public double Phone
- {
- get { return phone; }
- set { phone = value; }
- }
- public DateTime AddDate
- {
- get { return addDate; }
- set { addDate = value; }
- }
- public int TotalTransactions
- {
- get { return totalTransactions; }
- set { totalTransactions = value; }
- }
- //Work Methods
- public int CalcTransaction()
- {
- //Get current date
- DateTime currDate = DateTime.Now;
- //Get difference in months
- int months = currDate.Month - addDate.Month;
- //Get average transactions per month
- int avgTransactions = 0;
- if (months > 0) //If statement insures it doesn't divide by 0
- avgTransactions = totalTransactions / months;
- //Calculate discount
- int baseline = 3;
- int low = 6;
- int high = 15;
- int discount = 0;
- if (avgTransactions <= baseline)
- discount = 0;
- if (avgTransactions > low) //If has an average of 8 or more transactions per month, awarded 5% discount
- discount = 5;
- if (avgTransactions > high) //If has a an average of 15 or more transactions per month, awarded 10% discount
- discount = 10;
- return discount;
- //
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement