Archives from S:\ Drive
Good to keep around methinks
This commit is contained in:
1 parent
eadaf70b9e
commit
6dd63cc439
606 files changed
+50212
No files matched your search
@@ -0,0 +1,20 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||
# Visual Studio 2010
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Project3", "Project3\Project3.csproj", "{FFA33A1C-42BF-4496-A1B4-1A00294803D4}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x86 = Debug|x86
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{FFA33A1C-42BF-4496-A1B4-1A00294803D4}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{FFA33A1C-42BF-4496-A1B4-1A00294803D4}.Debug|x86.Build.0 = Debug|x86
|
||||
{FFA33A1C-42BF-4496-A1B4-1A00294803D4}.Release|x86.ActiveCfg = Release|x86
|
||||
{FFA33A1C-42BF-4496-A1B4-1A00294803D4}.Release|x86.Build.0 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,43 @@
|
||||
/*****************************************************************************
|
||||
* Project 2 will implement a payroll system using abstract classes. *
|
||||
* *
|
||||
* A company pays its employees on a weekly basis. The employees are of four *
|
||||
* types: Salaried employees are paid a fixed weekly salary regardless of the *
|
||||
* number of hours worked, hourly employees are paid by the hour and receive *
|
||||
* overtime pay for all hours worked in excess of 40 hours, commission *
|
||||
* employees are paid a percentage of their sales, and salaried commission *
|
||||
* employees receive a base salary plus a percentage of their sales. For the *
|
||||
* current pay period, the company has decided to reward salaried-commission *
|
||||
* employees by adding 10% to their base salaries. The company wants to *
|
||||
* implement a C# application that performs its payroll calculations *
|
||||
* polymorphically. *
|
||||
* *
|
||||
* Abstract base class Employee declares the “interface” to the hierarchy— *
|
||||
* that is, the set of methods that an application can invoke on all *
|
||||
* employee objects. Each employee, regardless of the way his earnings are *
|
||||
* calculated has a first name, a last name and a social security number, so *
|
||||
* private instance variables firstName, lastName and socialSecurityNumber *
|
||||
* appear in abstract base class Employee. *
|
||||
* *
|
||||
* Class Employee provides methods Earnings and ToString, in addition to the *
|
||||
* properties that manipulate Employee’s instance variables. An Earnings *
|
||||
* method certainly applies to all employees. But each earnings calculation *
|
||||
* depends on the employee’s class. So we declare Earnings as abstract in *
|
||||
* base class Employee. Each derived class overrides Earnings with an *
|
||||
* appropriate implementation. To calculate an employee’s earnings, the *
|
||||
* application assigns a reference to the employee’s object to a base class *
|
||||
* Employee variable, then invokes the Earnings method on that variable. *
|
||||
* You will maintain an array of Employee variables, each of which holds a *
|
||||
* reference to an Employee object. The application iterates through the *
|
||||
* array and calls method Earnings for each Employee object. C# processes *
|
||||
* theses method calls polymorphically. Including Earnings as an abstract *
|
||||
* method in Employee forces every directly derived class of Employee to *
|
||||
* override Earnings with a method that performs an appropriate pay *
|
||||
* calculation. *
|
||||
* *
|
||||
* Method ToString in class Employee returns a string containing the first *
|
||||
* name, last name, and social security number of the employee. Each derived *
|
||||
* class of Employee overrides method ToString to create a string *
|
||||
* representation of an object of that class containing the employee’s type, *
|
||||
* followed by the rest of the employee’s information. *
|
||||
*****************************************************************************/
|
||||
@@ -0,0 +1,85 @@
|
||||
/******************************************************************************
|
||||
* Project 3 uses interfaces to extend the payroll system developed *
|
||||
* in Project 2. *
|
||||
* *
|
||||
* Suppose that the company involved wants to perform several accounting *
|
||||
* operations in a single accounts-payable application—in addition to *
|
||||
* calculating the payroll earnings that must be paid to each employee, the *
|
||||
* company must also calculate the payment due on each of several invoices. *
|
||||
* Though applied to unrelated things, both operations have to do with *
|
||||
* calculating some kind of payment amount. For an employee, the payment *
|
||||
* refers to the employee’s earnings. For an invoice, the payment refers to *
|
||||
* the total cost of the goods listed on the invoice. Can we calculate such *
|
||||
* different things as the payments due for employees and invoices *
|
||||
* polymorphically in a single application? Does C# offer a capability that *
|
||||
* requires that unrelated classes implement a set of common methods? C# *
|
||||
* interfaces offer exactly this capability. *
|
||||
* *
|
||||
* Interfaces define and standardize the ways in which people and systems can *
|
||||
* interact with each other. For example, the controls on a radio serve as an *
|
||||
* interface between a user and the radio’s internal components. The controls *
|
||||
* allow users to perform a limited set of operations (e.g., changing the *
|
||||
* station, adjusting the volume, choosing between AM and FM), and different *
|
||||
* radios may implement the controls in different ways (e.g., using push *
|
||||
* buttons, dials, voice commands). The interface specifies what operations a *
|
||||
* radio must permit users to perform but does specify how the operations are *
|
||||
* performed. Similarly, the interface between a driver and a car with a *
|
||||
* manual transmission includes the steering wheel, the gear shift, the *
|
||||
* clutch pedal, the gas pedal and the brake pedal. This same interface is *
|
||||
* found in nearly all manual-transmission cars, enabling someone who knows *
|
||||
* how to drive one particular manual-transmission car to drive just about *
|
||||
* any manual-transmission car. The components may look a bit different, but *
|
||||
* the general purpose is the same—to allow people to drive the car. *
|
||||
* *
|
||||
* Software objects also communicate via interfaces. A C# interface describes *
|
||||
* a set of methods that can be called on an object, to tell the object to *
|
||||
* perform some task or return some piece of information, for example. The *
|
||||
* next part of Project Two introduces an interface named IPayable that *
|
||||
* describes the functionality of any object that must be capable of being *
|
||||
* paid and thus must offer a method to determine the proper amount due. an *
|
||||
* interface declaration begins with the keyword interface and can contain *
|
||||
* only abstract methods, properties, indexers, and events. All interface *
|
||||
* members are implicitly declared both public and abstract. In addition, *
|
||||
* each interface can extend one or more other interfaces to create a more *
|
||||
* elaborate interface that other classes can implement. *
|
||||
* *
|
||||
* To use an interface, a class must specify that it implements the *
|
||||
* interface by listing the interface after the colon ( : ) in the class *
|
||||
* declaration. Note that this is the same syntax used to indicate *
|
||||
* inheritance from a base class. A class implementing the interface must *
|
||||
* declare each member of the interface with the signature specified in the *
|
||||
* interface declaration. A class the implements an interface but does not *
|
||||
* implement all the interface’s members is an abstract class—it must be *
|
||||
* declared abstract and must contain an abstract declaration for each *
|
||||
* unimplemented member of the interface. Implementing an interface is like *
|
||||
* signing a contract with the compiler that states, “I will provide an *
|
||||
* implementation for all the members specified by the interface, or I will *
|
||||
* declare them abstract.” *
|
||||
* *
|
||||
* An interface is typically used when unrelated classes need to share common *
|
||||
* methods. This allows objects of unrelated classes to be processed *
|
||||
* polymorphically—objects of classes that implement the same interface can *
|
||||
* respond to the same method calls. Programmers can create an interface that *
|
||||
* describes the desired functionality, then implement this interface in any *
|
||||
* classes requiring that functionality. For example, in the accounts-payable *
|
||||
* application for this project, we implement interface IPayable in any class *
|
||||
* that must be able to calculate a payment amount. *
|
||||
* *
|
||||
* An interface often is used in place of an abstract class when there is no *
|
||||
* default implementation to inherit—that is, no fields and no default method *
|
||||
* implementations. Like public abstract classes, interfaces are typically *
|
||||
* public types, so they are normally declared in files by themselves with *
|
||||
* the same name as the interface and the .cs filename extension. *
|
||||
* *
|
||||
* To build an application that can determine payments for employees and *
|
||||
* invoices, you will create an interface named IPayable. Interface IPayable *
|
||||
* contains method GetPaymentAmount that returns a decimal amount that must *
|
||||
* be paid for an object of any class that implements the interface. Method *
|
||||
* GetPaymentAmount is a general purpose version of method Earnings of the *
|
||||
* Employee hierarchy—method Earnings calculates a payment amount specifically*
|
||||
* for an Employee, while GetPaymentAmount can be applied to a broad range of *
|
||||
* unrelated objects. After declaring interface IPayable, you will create *
|
||||
* class Invoice, which implements interface IPayable. Finally, you will *
|
||||
* update Employee derived classs SalariedEmployee to ‘fit’ into the IPayable *
|
||||
* hierarchy. *
|
||||
******************************************************************************/
|
||||
@@ -0,0 +1,43 @@
|
||||
/*****************************************************************************
|
||||
* Project: 2 - Payroll *
|
||||
* Description: Implement a payroll system using abstract classes *
|
||||
* Author: Amrit Panesar - 77260 *
|
||||
* License: Public Domain *
|
||||
* File description: Contains the member variables and functions for hybrid *
|
||||
* commission/salary based employees. *
|
||||
* For further description please see ARCHITECTURE2.txt *
|
||||
*****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Project3
|
||||
{
|
||||
public class BasePlusCommissionEmployee : CommissionEmployee
|
||||
{
|
||||
// overloaded constructor to call the Commission Employee's overloaded constructor
|
||||
public BasePlusCommissionEmployee(string FirstName, string LastName, string SSN, double ComissionRate, decimal GrossSales, decimal basesalary)
|
||||
: base(FirstName, LastName, SSN, ComissionRate, GrossSales)
|
||||
{
|
||||
BaseSalary = basesalary;
|
||||
}
|
||||
|
||||
public decimal BaseSalary { get; set; }
|
||||
|
||||
public override decimal Earnings()
|
||||
{
|
||||
// a salary/commission employee's wage is their salary + commission rate * gross sales
|
||||
return (((decimal)ComissionRate * GrossSales) + BaseSalary);
|
||||
}
|
||||
|
||||
// override the tostring method.
|
||||
public override string ToString()
|
||||
{
|
||||
// report employee tostring, gross sales, commission rate, and base salary
|
||||
return String.Format("base salaried commission employee: {0} {1}\nssn: {2}\ngross sales: {3}\ncommission rate: {4}\nbase salary: {5}\nearnings: {6}\n", FirstName, LastName, SocialSecuityNumber, GrossSales.ToString("C"), ComissionRate.ToString("F2"), BaseSalary.ToString("C"), Earnings().ToString("C"));
|
||||
// NOTE: we couldn't use the base.tostring method because it outputs commission employee strings.
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*****************************************************************************
|
||||
* Project: 2 - Payroll *
|
||||
* Description: Implement a payroll system using abstract classes *
|
||||
* Author: Amrit Panesar - 77260 *
|
||||
* License: Public Domain *
|
||||
* File description: Contains the member variables and functions for *
|
||||
* commission based employees. *
|
||||
* For further description please see ARCHITECTURE2.txt *
|
||||
*****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Project3
|
||||
{
|
||||
public class CommissionEmployee : Employee
|
||||
{
|
||||
// the main overloaded constructor, also call the base class Employee with it's overloaded constructor.
|
||||
public CommissionEmployee(string FirstName, string LastName, string SSN, double comissionrate, decimal grosssales ) : base( FirstName, LastName, SSN)
|
||||
{
|
||||
ComissionRate = comissionrate;
|
||||
GrossSales = grosssales;
|
||||
}
|
||||
|
||||
// constructor to pass an employee and arguments, if necessary.
|
||||
public CommissionEmployee(Employee empn, double comissionrate, decimal grosssales) : base (empn)
|
||||
{
|
||||
ComissionRate = comissionrate;
|
||||
GrossSales = grosssales;
|
||||
}
|
||||
|
||||
// constructor to pass an entire commission employee if necessary.
|
||||
public CommissionEmployee(CommissionEmployee empn) : base (empn)
|
||||
{
|
||||
ComissionRate = empn.ComissionRate;
|
||||
GrossSales = empn.GrossSales;
|
||||
}
|
||||
|
||||
public double ComissionRate { get; set; }
|
||||
public decimal GrossSales { get; set; }
|
||||
|
||||
public override decimal Earnings()
|
||||
{
|
||||
// a commission employee's earnings are the commission rate * gross sales
|
||||
return ((decimal)ComissionRate * GrossSales);
|
||||
}
|
||||
|
||||
// override the tostring method
|
||||
public override string ToString()
|
||||
{
|
||||
// the base tostring, gross sales, commission rate, and earnings
|
||||
return String.Format("commission {0}\ngross sales: {1}\ncommission rate: {2}\nearnings: {3}\n", base.ToString(), GrossSales.ToString("C"), ComissionRate.ToString("F2"), Earnings().ToString("C"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/*****************************************************************************
|
||||
* Project: 2 - Payroll *
|
||||
* Description: Implement a payroll system using abstract classes *
|
||||
* Author: Amrit Panesar - 77260 *
|
||||
* License: Public Domain *
|
||||
* File description: Houses the main driver for the program. Instantiates an *
|
||||
* array of 10 Employees that demonstrates polymorphic behavior *
|
||||
* For further description please see ARCHITECTURE2.txt *
|
||||
*****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Project3
|
||||
{
|
||||
public abstract class Employee : IPayable
|
||||
{
|
||||
// empty constructor, don't do anything.
|
||||
public Employee() { }
|
||||
|
||||
// main constructor, each value as a parameter.
|
||||
public Employee(string fname, string lname, string ssn)
|
||||
{
|
||||
FirstName = fname; LastName = lname; SocialSecuityNumber = ssn;
|
||||
}
|
||||
|
||||
// we have the flexibility to pass in an entire new employee if necessary.
|
||||
public Employee(Employee empn)
|
||||
{
|
||||
FirstName = empn.FirstName; LastName = empn.LastName; SocialSecuityNumber = empn.SocialSecuityNumber;
|
||||
}
|
||||
|
||||
public string FirstName { get; set; }
|
||||
public string LastName { get; set; }
|
||||
public string SocialSecuityNumber { get; set; }
|
||||
|
||||
// abstract. must be implemented by all other inherited classes.
|
||||
public abstract decimal Earnings();
|
||||
|
||||
// implement the IPayable interface in the employee class
|
||||
// this was the easiest thing to do since Earnings() already exists.
|
||||
public decimal GetPaymentAmount() // this is a project 3 addition
|
||||
{
|
||||
return Earnings();
|
||||
}
|
||||
|
||||
// override the tostring. this is the base tostring.
|
||||
public override string ToString()
|
||||
{
|
||||
// The standard employee: employee first name, last name, and social security number
|
||||
return String.Format("employee: {0} {1}\nssn: {2}", FirstName, LastName, SocialSecuityNumber);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/*****************************************************************************
|
||||
* Project: 2 - Payroll *
|
||||
* Description: Implement a payroll system using abstract classes *
|
||||
* Author: Amrit Panesar - 77260 *
|
||||
* License: Public Domain *
|
||||
* File description: Contains the member variables and functions for hourly *
|
||||
* employees. *
|
||||
* For further description please see ARCHITECTURE2.txt *
|
||||
*****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Project3
|
||||
{
|
||||
public class HourlyEmployee : Employee
|
||||
{
|
||||
// main constructor. pass variables to the Employee constructor
|
||||
public HourlyEmployee(string FirstName, string LastName, string SSN, decimal wage, double hours) : base(FirstName, LastName, SSN)
|
||||
{
|
||||
Wage = wage;
|
||||
Hours = hours;
|
||||
}
|
||||
|
||||
// We can pass in an employee object and extra variables, if necessary
|
||||
public HourlyEmployee(Employee empn, decimal wage, double hours) : base (empn)
|
||||
{
|
||||
Wage = wage;
|
||||
Hours = hours;
|
||||
}
|
||||
|
||||
// Or we can pass in an entire Hourly Employee and work with that.
|
||||
public HourlyEmployee(HourlyEmployee empn) : base(empn)
|
||||
{
|
||||
Wage = empn.Wage;
|
||||
Hours = empn.Hours;
|
||||
}
|
||||
|
||||
public decimal Wage { get; set; }
|
||||
public double Hours { get; set; }
|
||||
|
||||
public override decimal Earnings()
|
||||
{
|
||||
if (Hours <= 40) // if the employee's hours are less than 40 inclusive
|
||||
{
|
||||
return (Wage * 40); // multiply the wage by 40 hours
|
||||
}
|
||||
else if (Hours > 40) // if the employee's hours are more than 40
|
||||
{
|
||||
return (decimal)(40 * (double)Wage + (Hours - 40) * (double)Wage * 1.5); // the standard wage + time and a half for all hours over 40
|
||||
}
|
||||
else // this should never happen.
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// override the tostring
|
||||
public override string ToString()
|
||||
{
|
||||
//the standard employee tostring, hourly wage, hours worked, and earnings
|
||||
return String.Format("hourly {0}\nhourly wage: {1}\nhours worked: {2}\nearnings: {3}\n", base.ToString(), Wage.ToString("C"), Hours.ToString("F2"), Earnings().ToString("C"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
/*****************************************************************************
|
||||
* Project: 3 - Payroll Interface *
|
||||
* Description: Implement a payroll system using abstract classes and *
|
||||
* interfaces *
|
||||
* Author: Amrit Panesar - 77260 *
|
||||
* License: Public Domain *
|
||||
* File description: Contains the required functions to be implemented in *
|
||||
* classes that implement this interface *
|
||||
* For further description please see ARCHITECTURE3.txt *
|
||||
*****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Project3
|
||||
{
|
||||
interface IPayable
|
||||
{
|
||||
// GetPaymentAmount() must be implemented by everyone who uses this interface
|
||||
decimal GetPaymentAmount();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*****************************************************************************
|
||||
* Project: 3 - Payroll Interface *
|
||||
* Description: Implement a payroll system using abstract classes and *
|
||||
* interfaces *
|
||||
* Author: Amrit Panesar - 77260 *
|
||||
* License: Public Domain *
|
||||
* File description: Contains the member variables and functions for a *
|
||||
* generic Invoice and accounts payable interface. *
|
||||
* For further description please see ARCHITECTURE3.txt *
|
||||
*****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Project3
|
||||
{
|
||||
class Invoice : IPayable
|
||||
{
|
||||
// default constructor
|
||||
public Invoice() { }
|
||||
|
||||
// the main constructor, sets payment right away
|
||||
public Invoice(decimal payment)
|
||||
{
|
||||
PaymentAmount = payment;
|
||||
}
|
||||
|
||||
// implement the IPayable interface
|
||||
public decimal PaymentAmount { get; set; }
|
||||
|
||||
// return the payment amount variable for the interface
|
||||
public decimal GetPaymentAmount()
|
||||
{
|
||||
return PaymentAmount;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
/*****************************************************************************
|
||||
* Project: 2 - Payroll *
|
||||
* Description: Implement a payroll system using abstract classes *
|
||||
* Author: Amrit Panesar - 77260 *
|
||||
* License: Public Domain *
|
||||
* File description: Houses the main driver for the program. Instantiates an *
|
||||
* array of 10 Employees that demonstrates polymorphic behavior *
|
||||
* For further description please see ARCHITECTURE2.txt *
|
||||
*****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Project3
|
||||
{
|
||||
public partial class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
// Use an array list to house our employees.
|
||||
ArrayList empn = new ArrayList();
|
||||
|
||||
// generate 5 to 30 random employees..
|
||||
int highOrder = RandNumber(5, 30);
|
||||
|
||||
Console.WriteLine("Generating {0} Employees...", highOrder);
|
||||
|
||||
// loop though the random number above
|
||||
for (int i = 0; i < highOrder; i++)
|
||||
{
|
||||
int thisN = RandNumber() % 5; // Generate a random number between 1 and the max integer size moded by 5 (to generate a number 1-4)
|
||||
switch (thisN)
|
||||
{
|
||||
case 4: // BasePlus
|
||||
empn.Add(new BasePlusCommissionEmployee(GenerateFirstName(), GenerateLastName(), GenerateSSN(), RandDouble(), (decimal)RandDouble(), (decimal)RandDouble()));
|
||||
break;
|
||||
case 3: // Commission
|
||||
empn.Add(new CommissionEmployee(GenerateFirstName(), GenerateLastName(), GenerateSSN(), RandDouble(), (decimal)RandDouble()));
|
||||
break;
|
||||
case 2: // Salary
|
||||
empn.Add(new SalariedEmployee(GenerateFirstName(), GenerateLastName(), GenerateSSN(), (decimal)RandDouble()));
|
||||
break;
|
||||
default: // Hourly
|
||||
empn.Add(new HourlyEmployee(GenerateFirstName(), GenerateLastName(), GenerateSSN(), (decimal)RandDouble(), RandDouble()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Loop through the new array list.
|
||||
for (int i = 0; i < empn.Count; i++ )
|
||||
{
|
||||
Console.WriteLine("\n================Employee #: {0}================", (i + 1)); // spit out the sequence number
|
||||
Console.WriteLine(empn[i]); // tostring method. so much easier.
|
||||
Console.WriteLine("GetPaymentAmount(): {0}", ((Employee)empn[i]).GetPaymentAmount().ToString("C")); // project 3 change
|
||||
// remind me to always override the tostring() method.
|
||||
}
|
||||
|
||||
/**************************begin project 3 changes****************/
|
||||
|
||||
// make an array list to satisfy the project 3 requirements
|
||||
ArrayList invoices = new ArrayList();
|
||||
|
||||
// generate a new highOrder for invoices. between 5 and 30 again
|
||||
highOrder = RandNumber(5, 30);
|
||||
|
||||
// add a random amount of invoices with a random value to our array list
|
||||
for (int i = 0; i < highOrder; i++)
|
||||
{
|
||||
invoices.Add(new Invoice((decimal)RandDouble())); //instantiate a new Invoice with a new random value
|
||||
}
|
||||
|
||||
// loop through our newly added invoices
|
||||
for (int i = 0; i < invoices.Count; i++)
|
||||
{
|
||||
Console.WriteLine("\n================Invoice #: {0}================", (i + 1)); // output sequence number
|
||||
Console.WriteLine("GetPaymentAmount: {0}", ((Invoice)invoices[i]).GetPaymentAmount().ToString("C")); // and information
|
||||
}
|
||||
|
||||
// courtesy line and direction.
|
||||
Console.WriteLine("\n----------------------------------------\nPress ENTER to continue");
|
||||
// let's keep the console from closing.
|
||||
Console.ReadLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{FFA33A1C-42BF-4496-A1B4-1A00294803D4}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Project3</RootNamespace>
|
||||
<AssemblyName>Project3</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<PublishUrl>publish\</PublishUrl>
|
||||
<Install>true</Install>
|
||||
<InstallFrom>Disk</InstallFrom>
|
||||
<UpdateEnabled>false</UpdateEnabled>
|
||||
<UpdateMode>Foreground</UpdateMode>
|
||||
<UpdateInterval>7</UpdateInterval>
|
||||
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||
<UpdatePeriodically>false</UpdatePeriodically>
|
||||
<UpdateRequired>false</UpdateRequired>
|
||||
<MapFileExtensions>true</MapFileExtensions>
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<StartupObject>Project3.Program</StartupObject>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<SignManifests>false</SignManifests>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<SignAssembly>false</SignAssembly>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="BasePlusCommissionEmployee.cs" />
|
||||
<Compile Include="Invoice.cs" />
|
||||
<Compile Include="CommissionEmployee.cs" />
|
||||
<Compile Include="Employee.cs" />
|
||||
<Compile Include="HourlyEmployee.cs" />
|
||||
<Compile Include="IPayable.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="RandomThings.cs" />
|
||||
<Compile Include="SalariedEmployee.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="ARCHITECTURE3.txt" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="ARCHITECTURE2.txt" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include=".NETFramework,Version=v4.0,Profile=Client">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>Microsoft .NET Framework 4 Client Profile %28x86 and x64%29</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>Windows Installer 3.1</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("Project2")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Coleman University")]
|
||||
[assembly: AssemblyProduct("Project2")]
|
||||
[assembly: AssemblyCopyright("Copyright © Coleman University 2013")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("49380830-1af5-4d23-9477-5145a019c8bf")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
@@ -0,0 +1,80 @@
|
||||
/*****************************************************************************
|
||||
* Project: 2 - Payroll *
|
||||
* Description: Implement a payroll system using abstract classes *
|
||||
* Author: Amrit Panesar - 77260 *
|
||||
* License: Public Domain *
|
||||
* File description: Houses the random functions found in the file Program.cs *
|
||||
* The functions RandNumber(), RandDouble(), GenerateFirstName(), and *
|
||||
* GenerateLastName() can all be found in this file. *
|
||||
* For further description please see ARCHITECTURE2.txt *
|
||||
*****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Project3
|
||||
{
|
||||
public partial class Program
|
||||
{
|
||||
// generate a random number from 0 to the maximum value an integer can hold. Positive values.
|
||||
public static int RandNumber(int Low = 0, int High = int.MaxValue)
|
||||
{
|
||||
Random rndNum = new Random(int.Parse(Guid.NewGuid().ToString().Substring(0, 8), NumberStyles.HexNumber));
|
||||
int rnd = rndNum.Next(Low, High);
|
||||
return rnd;
|
||||
}
|
||||
|
||||
// generate a random floating point double. positive values.
|
||||
public static double RandDouble()
|
||||
{
|
||||
Random rndNum = new Random(int.Parse(Guid.NewGuid().ToString().Substring(0, 8), NumberStyles.HexNumber));
|
||||
double rnd = rndNum.NextDouble() * 28;
|
||||
if (rnd < 20) // make all numbers greater than 20.
|
||||
{
|
||||
rnd *= RandDouble();
|
||||
}
|
||||
return rnd;
|
||||
}
|
||||
|
||||
// grab a random firstname from this string array.
|
||||
public static string GenerateFirstName()
|
||||
{
|
||||
string[] firstnames = { "Librada","Jeanne","Krishna","Roni","Kisha","Edison","Freda","Jed","Lorraine","Nelda","Corine","Lien","Daisy","Gita","Suzy","Gwyneth","Krysta","Erinn","Samual","Barney","Rosia","Malik","Franchesca","Cherryl","Ricardo","Inga","Lesley","Kory","Jaunita","Lacey","Chelsie","Kera","Isaac","Aracely","Delmy","Maggie","Rolland","Estela","Otha","Arturo","Devona",
|
||||
"Wilton","Karey","Hillary","Jared","Tiffiny","Boris","Flavia","Rivka","Casimira","Adria","Odette","Wilbert","Xuan","Allyson","Rosendo","Elijah","Tad","Malisa","Kayleen","Jone","Reina","Laraine","Len","Leora","Fred","Sydney","Sona","Thuy","Sage","Sixta","Joseph","Chantell","Kiesha","Kacie","Maryellen","Fidelia","Anastasia","Stephaine","Johanne","Charlesetta",
|
||||
"Crista","Jarod","Sherrell","Sebrina","Juliet","Charise","Candida","Jonnie","Daine","Jong","Maida","Danilo","Jeneva","Margret","Domenic","Luanna","Nana","Salley","Hipolito","Sanjuanita","Giuseppina","Domonique","Shayla","Melva","Leora","Ashleigh","Ruben","Delbert","Evelina","Jeanie","Margarett","Marcie","Assunta","Latoria","Jodie","Kenisha","Anamaria","Shirleen",
|
||||
"Ashton","Yan","Fanny","Vanita","Marlyn","Maryland","Shandi","Adolph","Amina","Manuel","Dawne","Cristine","Alberto","Tabetha","Frida","Awilda","Louann","Karly","Dede","Kristina","Sue","Elissa","Jamika","Margret","Ninfa","Louisa","Vinita","Gigi","Quinn","Maricruz","Jeanmarie","Niesha","Marquita","Hertha","Shawnna","Jetta","Kristel","Shaunta","Kiyoko","Alana","Eduardo",
|
||||
"Trish","Willa","Darline","Ching","Rosenda","Rufus","Kraig","Tia","Keely","Markita","Georgann","Nicola","Judy","Ignacio","Shantay","Cicely","Astrid","Ladawn","Nia","Babara","Deidre","Geoffrey","Leilani","Lamont","Delphine","Harrison","Anjanette","Zona","Carmen","Hui","Luvenia","Leeann","Marybelle","Shanon","Nicky","Carlene","Laquanda","Aldo","Larisa","Tony",
|
||||
"Madeleine","Garnett","Shae","Shemika","Erich","Celestina","Foster","Kaitlyn","Mariela","Noe","Rafael","Jesusa","Cole","Lettie","Sherill","Trey","Marg","Shaunda","Randell","Piedad","Marjorie","Verena","Elicia","Mika","Colette","Corene","Veronika","Jerrie","Rosie","Georgene","Serafina","Sherman","Susannah","Annamae","Michell","Kelsey","Rosario","Carolina","Jeanie",
|
||||
"Lyndia","Ora","Herta","Santa","Erline","Karmen","Griselda","Maud","Linnie","Nicholle","Mistie","Jordan"};
|
||||
// use the positive random number function above, mod'd by the length to grab a random value
|
||||
return (firstnames[RandNumber() % firstnames.Length]);
|
||||
}
|
||||
|
||||
// grab a random lastname from this string array.
|
||||
public static string GenerateLastName()
|
||||
{
|
||||
string[] lastnames = { "Ives","Dole","Bechtel","Gilfillan","Fahey","Montrose","Harvin","Arvizo","Letarte","Reidhead","Ahlstrom","Hyneman","Reynoso","Douglass","Prato","Mccutchen","Mohl","Sperry","Greb","Cabell","Laramore","Fujiwara","Arpin","Brumfield","Fortin","Markell","Ballengee","Sanluis","Trickey","Haake","Zirkle","Gaines","Ahern","Lafond","Jude","Robie","Runion","Runyan","Futrell",
|
||||
"Rather","Kinloch","Rugg","Senecal","Vanhook","Vallance","Stillwell","Haldeman","Thrush","Shomo","Valerius","Cazares","Townley","Rakestraw","Agar","Meinecke","Coll","Redick","Saint","Spight","Mcnaught","Gayman","Yerger","Rivero","Fabela","Wilhoite","Middlebrooks","Jefferys","Massie","Reichel","Lobb","Ristow","Rucks","Heckard","Hosmer","Dingess","Schamber","Hesson",
|
||||
"Torbett","Goldschmidt","Hayter","Shew","Ugalde","Vicknair","Danks","Tate","Delorme","Ormand","Laughton","Wilkerson","Dickson","Mulvey","Junkin","Camacho","Barsh","Recker","Farnsworth","Gary","Drees","Knoles","Satter","Battin","Costa","Matsumura","Shears","Devinney","Macken","Garrett","Doney","Fulmer","Hoss","Loll","Tanner","Podesta","Asaro","Morningstar","Hilyard",
|
||||
"Nehls","Fonseca","Eller","Wilkinson","Lamarca","Soliz","Westervelt","Carlino","Kunkle","Loucks","Jansson","Cothren","Darlington","Zahm","Pinegar","Emerick","Tall","Eveland","Umstead","Davisson","Batz","Plata","Ryberg","Beane","Koening","Putz","Daughtrey","Sinha","Gerdes","Arno","Lorch","Shehan","Chenard","Holloway","Castleberry","Bowlin","Battin","Donovan","Calton",
|
||||
"Huot","Mcmurtrie","Delapp","Lankford","Biel","Kin","Caceres","Ormand","Streicher","Kimbrel","Cornish","Barahona","Southern","Stuart","Stoke","Scharff","Hartwell","Gildersleeve","Tedrick","Rex","Chaudhry","Wetzel","Desai","Ensey","Escobedo","Matranga","Falzone","Ritzman","Marchant","Babin","Friedt","Shoup","Gunder","Seim","Shadrick","Riggs","Moret","Howes","Steenbergen",
|
||||
"Rodriques","Dries","Jefferson","Hulbert","Menendez","Ellington","Housand","Whitwell","Rearick","Wagnon","Schmitmeyer","Barhorst","Rosenfield","Summerville","Matus","Marrow","Kind","Searfoss","Denn","Appling","Grim","Huffer","Kellen","Roscoe","Garofalo","Simeone","Goucher","Parkhurst","Tarpey","Bassett","Ortman","Segundo","Mattson","Pullum","Kriner","Smiddy","Cohrs",
|
||||
"Loring","Strebel","Mcnemar","Grossi","Raby","Dubray","Capra","Wittrock","Fazzino","Bedard","Sera","Lisk","Heldt","Barefoot","Heimbach","Hover","Guthrie","Hartigan","Noyes","Jarrard"};
|
||||
// use the positive random number function above, mod'd by the length to grab a random value
|
||||
return (lastnames[RandNumber() % lastnames.Length]);
|
||||
}
|
||||
|
||||
// make a random social security number
|
||||
public static string GenerateSSN()
|
||||
{
|
||||
int G1 = RandNumber(1, 1000);
|
||||
int G2 = RandNumber(1, 100);
|
||||
int G3 = RandNumber(1, 10000);
|
||||
// use the string.format and tostring methods to numerically pad each tuple of a social security number
|
||||
return String.Format("{0}-{1}-{2}", G1.ToString("D3"), G2.ToString("D2"), G3.ToString("D4"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*****************************************************************************
|
||||
* Project: 2 - Payroll *
|
||||
* Description: Implement a payroll system using abstract classes *
|
||||
* Author: Amrit Panesar - 77260 *
|
||||
* License: Public Domain *
|
||||
* File description: Contains the member variables and functions for salaried *
|
||||
* employees. *
|
||||
* For further description please see ARCHITECTURE2.txt *
|
||||
*****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Project3
|
||||
{
|
||||
public class SalariedEmployee : Employee
|
||||
{
|
||||
// main constructor for the salaried employee
|
||||
public SalariedEmployee(string FirstName, string LastName, string SSN, decimal weeklysal) : base(FirstName, LastName, SSN)
|
||||
{
|
||||
WeeklySalary = weeklysal;
|
||||
}
|
||||
public decimal WeeklySalary { get; set; }
|
||||
|
||||
public override decimal Earnings()
|
||||
{
|
||||
// a salaried employee's earnings are his/her weekly salary.
|
||||
return WeeklySalary;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
// the standard employee tostring, weekly salary, and earnings
|
||||
return String.Format("salaried {0}\nweekly salary: {1}\nearnings: {2}\n",base.ToString(),WeeklySalary.ToString("C"),Earnings().ToString("C"));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user