MCC - CIS162AD
CS8 Classes - 15 points![]()
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:
- The form file and skeleton class files for this assignment are provided as a self-extracting archive. It also includes the program code (driver) that must be used to test the class definitions.
- Download and expand the self-extracting archive CS8 Classes
- Open the solution file (CS8.sln).
- Note: There will be many undeclared variables until the required classes are defined and the Preferred Discount checkbox is not used until CS9.
- Use the UML Class Diagram below to determine the variables, property methods, and constructors that should be included in each of the two classes (clsCustomer, clsOrder). The diagram also specifies which access modifier to apply to each item in the class (public, private, or protected).
- In order for the program to work as provided, you should use the variable and method names provided in the UML Class Diagram when building the class definitions. If you deviate from the suggested names, the corresponding changes will need to be made to the source code provide.
- We will NOT be including data validation in this assignment, so the set methods should NOT include any If statements to validate the data. To test data validation included in class definitions would require us to throw an exception, but that is beyond the scope of this assignment :-(.
Sample form:
![]()
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 ClassSubmit the two class files: clsCustomer.cs and clsOrder.cs
Revised: 10/20/2009 - www.mesacc.edu/~marquez/cis162ad/cs8_classes.html