MCC - CIS162AD
CS8 Classes - 15 points
   cs.gif

There are 2 object-oriented programming assignments (CS8 and CS9) that build on each other, so CS9 may NOT be started until CS8 has been completed.

Description:
For CS8 create two class definitions: one for customer information, one for the items ordered (see the class diagrams below). The order class should perform the calculations and maintain the summary information in shared (static) variables. Classes are just a definition of a data type. A program that is written to test the classes is referred to as a driver. The driver and class design is provided (see below), so students basically just need to enter the code for the class definitions. The driver program should work as is if the suggested variable and method names listed in the UML Class Diagrams are used.

How to Complete Assignment:

Sample form:

Sample Form (cs8_interface.jpg)

Test Data:

Enter any name and address to see if the data displays as a mailing label.

Description Quantity Price Extension
Flower Pot 2 19.95 39.90
Mailbox 1 24.95 24.95
Planter 3 21.95 65.85

Totals: 3 130.70

UML - Class Diagrams:

Symbol definitions:
- private
+ public
# protected
* shared (static) methods that referenced shared variables must also be declared shared
% read-only

clsCustomer   clsOrder
- string cstrName
- string cstrStreet
- string cstrCity
- string cstrState
- string cstrZip
# string cstrDescription
# int cintQuantity
# decimal cdecPrice
# decimal cdecExtendedPrice

(Shared Variables)
# * static decimal cdecTotalPrice
# * static int cintTotalCount

+ clsCustomer( )
    default constructor

+ clsCustomer(string strName,
    string strStreet, string strCity,
    string strState, string strZip)

    Overloaded constructor
    Use property methods
    to assign parameter
    values to class variables.
    this.Name = strName

+ set & get string Name
+ set & get string Street
+ set & get string City
+ set & get string State
+ set & get string Zip

+ clsOrder( )
    default constructor

+ clsOrder(string strDescription,
    int intQuantity, decimal decPrice)


    Overloaded constructor
    Use property methods
    to assign parameter
    values to class variables.
    this.Description = strDescription

+ set & get string Description
+ set & get int Quantity
+ set & get decimal Price

(read-only property)
+ % get decimal ExtendedPrice

(Shared read-only property)
+ * % static decimal get TotalPrice
+ * % static int get TotalCount

(Supporting Methods)
+ void calcExtendedPrice( )
+ void accumulateTotals( )
+ * static void resetTotals( )







Partial Code included in Order Class:

public class clsOrder
{
  //declare class variables
  //declare constructors
  //declare property methods

  //declare read-only properties
    public decimal ExtendedPrice 
    {
        get
        {
            return cdecExtendedPrice;
        }
    }

  //declare Shared (static) ReadOnly Properites
    public static decimal TotalPrice 
    {
        get
        {
            return cdecTotalPrice;
        }
    }

    public static int TotalCount 
    {
        get
        {
            return cintTotalCount;
        }
    }

  //declare supporting methods
    public void calcExtendedPrice()
    {
        cdecExtendedPrice = cintQuantity * cdecPrice;
    }

    public void accumulateTotals()
    {
        cdecTotalPrice += cdecExtendedPrice;
        cintTotalCount += 1;
    }

    public static void resetTotals()
    {
        cdecTotalPrice = 0;
        cintTotalCount = 0;
    }

}//End of Class

Submit the two class files: clsCustomer.cs and clsOrder.cs


Revised: 10/20/2009 - www.mesacc.edu/~marquez/cis162ad/cs8_classes.html