I have a assignment from school that I'm having trouble with. I need the program to beable to do... Can someone help me with what I'm doing wrong?

* Input an order ( NumberOfPizzas and NumberOfCokes)
* Compute the OrderAmount = (NumberOfPizzas * decPIZZAPRICE + NumberOfCokes * decCOKEPRICE)
* Compute SalesTax = OrderAmount * decSALESTAXRATE
* Compute AmountDue = OrderAmount + SalesTax
* Display OrderAmount, SalesTax, AmountDue
* Input AmountPaid
* Compute Change = AmountPaid - AmountDue
* Displays Change
* Allows the user to view all the orders placed and a summary of sales for the day (Cokes and Pizzas, total number and $$ amount, and average sale at a minimum.)

Requirements:
Order class
numberOfPizzas
numberOfCokes

methods
InputOrder
GetAmountDue
GetChangedue

DailySummary
private Orders() as Order
numberOfCokes
numberOfPizzas
totalOfCokes
totalOfPizzas

methods
StoreOrder
GetOrder


Figure 1. Mid-Term UML Class diagram

1. Implement the UML class diagram in figure 1 (25 pts)(Note that you can use an arraylist of Order objects in your DailySummary class to make things simpler)
2. (25 pts) Create an order class and instantiate it for each order placed. The order class should have the following methods (at a minimum, you may decide you need more):
* inputOrder (numberOfPizzas, numberOfCokes)
* getAmountDue (which might use private methods to compute orderAmount & salesTax)
* getChangeDue

3. (25 pts) Create a DailySummary class that stores each order and calculates summary information for the day. Store each order object created in an attribute of the DailySummary class. (hint: use a private arraylist in the DailySummary Class to store your orders. Create accessor methods to store and retrieve order info. Create class variables and methods as needed to retrieve order summary data.

4. Design a form (or forms) with the necessary text boxes and buttons to perform the task.

5. Provide some means by which a user can view a summary of the days orders (which will access your DailySummary class)
6. Use a multi-line textbox for all output. Use appropriate formatting for output. Your output should be very similar to (though not necessarily identical):


4 Pizzas @ 8.99: $35.96
5 Cokes @ .99: $4.95
Order Amount: $40.91
Sales Tax: $2.66
Amount Due: $43.57
Amount Paid: $50.00
Change Due: $6.43

My code...

Order Class

Public Class Order

    'Constant variables
    Public Const PIZZA_PRICE As Double = 8.99
    Public Const COKE_PRICE As Double = 0.99
    Public Const SALES_TAX_RATE As Double = 0.065

    Private numberOfPizzas As Double
    Private numberOfCokes As Double
    Private amountPaid As Double
    Private amountDue As Double
    Private changeDue As Double

    Private theDailySummary As DailySummary



    Public Sub New(ByVal aNumberOfPizzas As Double, ByVal aNumberOfCokes As Double, ByVal anAmountPaid As Double)
        SetNumberOfPizzas(aNumberOfPizzas)
        SetNumberOfCokes(aNumberOfCokes)
        SetAmountPaid(anAmountPaid)
        OrderAmount()
        SalesTax()
        SetAmountDue()
        SetChangeDue()
    End Sub

    Public Overrides Function ToString() As String
        Return numberOfPizzas & " Pizzas @ " & FormatCurrency(PIZZA_PRICE) & ": " & (numberOfPizzas * PIZZA_PRICE) & vbNewLine & _
        numberOfCokes & " Cokes @ " & FormatCurrency(COKE_PRICE) & ": " & (numberOfCokes * COKE_PRICE) & vbNewLine & _
        " Order Amount: " & FormatCurrency(OrderAmount()) & vbNewLine & _
        " Sales Tax: " & FormatCurrency(SalesTax()) & vbNewLine & _
        " Amount Due: " & FormatCurrency(amountDue) & vbNewLine & _
        " Amount Paid: " & FormatCurrency(amountPaid) & vbNewLine & _
        " Change Due: " & FormatCurrency(changeDue)
    End Function

    Public Function OrderAmount() As Double
        Dim aOrderAmount As Double
        aOrderAmount = (numberOfPizzas * PIZZA_PRICE + numberOfCokes * COKE_PRICE)
        Return aOrderAmount
    End Function

    Public Function SalesTax() As Double
        Dim aSalesTax As Double
        aSalesTax = (OrderAmount() * SALES_TAX_RATE)
        Return aSalesTax
    End Function

    Public Function GetAmountDue() As Double
        Return amountDue
    End Function

    Public Sub SetAmountDue()
        amountDue = OrderAmount() + SalesTax()
    End Sub

    Public Function GetChangeDue() As Double
        Return changeDue
    End Function

    Public Sub SetChangeDue()
        changeDue = amountPaid - amountDue
    End Sub

    Public Function GetNumberOfPizzas() As Double
        Return numberOfPizzas
    End Function

    Public Sub SetNumberOfPizzas(ByVal aNumberOfPizzas As Double)
        numberOfPizzas = aNumberOfPizzas
    End Sub

    Public Function GetNumberOfCokes() As Double
        Return numberOfCokes
    End Function

    Public Sub SetNumberOfCokes(ByVal aNumberOfCokes As Double)
        numberOfCokes = aNumberOfCokes
    End Sub

    Public Function GetAmountPaid() As Double
        Return amountPaid
    End Function

    Public Sub SetAmountPaid(ByVal anAmountPaid As Double)
        amountPaid = anAmountPaid
    End Sub

    Public Sub SetDailySummary(ByVal aDailySummary As DailySummary)
        theDailySummary = aDailySummary
    End Sub


End Class

DailySummary class

Public Class DailySummary
    Inherits Order

    Private orders As New ArrayList()
    
    Private totalOfPizzas As Double
    Private totalOfCokes As Double
    Private summaryDate As Date
    Private totalOrderAmount As Double
    Private totalAmountDue As Double
    Private totalAmountPaid As Double
    Private totalChangeDue As Double
    Private totalSalesTax As Double

    Private theOrder As Order

    Public Sub New(ByVal aNumberOfPizzas As Double, ByVal aNumberOfCokes As Double, ByVal anAmountPaid As Double)
        MyBase.New(aNumberOfPizzas, aNumberOfCokes, anAmountPaid)
        SetTotalOfCokes(aNumberOfPizzas)
        SetTotalOfPizzas(aNumberOfCokes)
        SetTotalAmountPaid(anAmountPaid)
        SetTotalAmountDue(GetAmountDue())
        SetTotalChangeDue(GetChangeDue())
        SetTotalSalesTax(SalesTax())
        SetTotalOrderAmount(OrderAmount())
        AssignOrderToOrder(aNumberOfPizzas, aNumberOfCokes, anAmountPaid)
       

    End Sub

    Public Overrides Function ToString() As String
        Return totalOfPizzas & " Pizzas @ " & FormatCurrency(PIZZA_PRICE) & ": " & (totalOfPizzas * PIZZA_PRICE) & vbNewLine & _
        totalOfCokes & " Cokes @ " & FormatCurrency(COKE_PRICE) & ": " & (totalOfCokes * COKE_PRICE) & vbNewLine & _
        " Order Amount: " & FormatCurrency(totalOrderAmount) & vbNewLine & _
        " Sales Tax: " & FormatCurrency(totalSalesTax) & vbNewLine & _
        " Amount Due: " & FormatCurrency(totalAmountDue) & vbNewLine & _
        " Amount Paid: " & FormatCurrency(totalAmountPaid) & vbNewLine & _
        " Change Due: " & FormatCurrency(totalChangeDue)
    End Function

    Public Sub StoreOrder(ByVal aOrders As Order)
        orders.Add(aOrders)
    End Sub

    'get accessor methods

    Public Function GetOrder() As ArrayList
        Return orders
    End Function

    Public Function GetTotalOrderAmount() As Double
        Return totalOrderAmount
    End Function

    Public Function GetTotalAmountDue() As Double
        Return totalAmountDue
    End Function

    Public Function GetTotalAmountPaid() As Double
        Return totalAmountPaid
    End Function

    Public Function GetTotalChangeDue() As Double
        Return totalChangeDue
    End Function

    Public Function GetTotalSalesTax() As Double
        Return totalSalesTax
    End Function

    Public Sub AssignOrderToOrder(ByVal aNumberOfPizzas As Double, ByVal aNumberOfCokes As Double, ByVal anAmountPaid As Double)
        Dim order1 As New Order(aNumberOfPizzas, aNumberOfCokes, anAmountPaid)
        SetOrder(order1)
        order1.SetDailySummary(Me)
    End Sub

    Public Function GetTotalOfPizzas() As Double
        Return totalOfPizzas
    End Function

    Public Function GetTotalOfCokes() As Double
        Return totalOfCokes
    End Function
    Public Function GetSummaryDate() As Date
        Return summaryDate
    End Function

    'set accessor methods
    Public Sub SetTotalOfPizzas(ByVal aTotalOfPizzas As Double)
        totalOfPizzas += aTotalOfPizzas
    End Sub

    Public Sub SetTotalOfCokes(ByVal aTotalOfCokes As Double)
        totalOfCokes += aTotalOfCokes
    End Sub
    Public Sub SetSummarydate(ByVal aSummaryDate As Date)
        summaryDate = aSummaryDate
    End Sub

    Public Sub SetOrder(ByVal aOrder As Order)
        theOrder = aOrder
    End Sub

    Public Sub SetTotalAmountDue(ByVal aTotalAmountDue As Double)
        totalAmountDue += aTotalAmountDue
    End Sub

    Public Sub SetTotalOrderAmount(ByVal aTotalOrderAmount As Double)
        totalOrderAmount += aTotalOrderAmount
    End Sub

    Public Sub SetTotalAmountPaid(ByVal aTotalAmountPaid As Double)
        totalAmountPaid += aTotalAmountPaid
    End Sub

    Public Sub SetTotalChangeDue(ByVal aTotalChangeDue As Double)
        totalChangeDue += aTotalChangeDue
    End Sub

    Public Sub SetTotalSalesTax(ByVal aTotalSalesTax As Double)
        totalSalesTax += aTotalSalesTax
    End Sub


End Class

Ordertester class

Public Class OrderTester
    Inherits System.Windows.Forms.Form

    'Declare order reference variable
    Private aDailySummary As DailySummary
    Private aOrder As Order

    'Declare string variables for numberOfPizzas and numberOfCokes
    Private custNumOfPizzas, custNumOfCokes As Double
    Private custNumOfPizzas2, custNumOfCokes2 As Double
    Private custAmtPaid As Double
    Private custAmtPaid2 As Double

    Private Sub btnTotal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTotal.Click
        custNumOfPizzas = txtPizza.Text
        custNumOfCokes = txtCoke.Text
        custAmtPaid = 0

        Dim order1 As New Order(custNumOfPizzas, custNumOfCokes, custAmtPaid)
        txtTotal.Text = (FormatCurrency(order1.GetAmountDue()))
    End Sub

    Private Sub ClearForm()
        txtPizza.Text = ""
        txtCoke.Text = ""
        txtTotal.Text = ""
        txtAmtPaid.Text = ""
    End Sub

    'Private Sub Order()
    '    Dim order1 As New Order(custNumOfPizzas, custNumOfCokes, custAmtPaid)
    'End Sub

    Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
        ClearForm()
    End Sub

    Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
        Me.Close()
    End Sub

    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtOutput.TextChanged

    End Sub

    Private Sub btnViewSummary_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
    End Sub

  


    Private Sub btnPlcOrder_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPlcOrder.Click

        custNumOfPizzas = txtPizza.Text
        custNumOfCokes = txtCoke.Text
        custAmtPaid = txtAmtPaid.Text

        Dim order1 As New Order(custNumOfPizzas, custNumOfCokes, custAmtPaid)

        Dim dailySummary As New DailySummary(custNumOfPizzas, custNumOfCokes, custAmtPaid)

        dailySummary.StoreOrder(order1)

        txtOutput.Text = dailySummary.ToString

        txtReceipt.Text = order1.ToString

        ClearForm()


    End Sub



    Private Sub btnViewAllOrders_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub txtReceipt_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtReceipt.TextChanged

    End Sub

    Private Sub TextBox3_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub TextBox1_TextChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub
End Class

I didn't get any errors. I just can't seem to get the arraylist to keep the history of all the individual orders so I can print a end of day summary receipt.

Private Sub btnPlcOrder_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPlcOrder.Click

        custNumOfPizzas = txtPizza.Text
        custNumOfCokes = txtCoke.Text
        custAmtPaid = txtAmtPaid.Text

        Dim order1 As New Order(custNumOfPizzas, custNumOfCokes, custAmtPaid)

        Dim dailySummary As New DailySummary(custNumOfPizzas, custNumOfCokes, custAmtPaid)

        dailySummary.StoreOrder(order1)

        txtOutput.Text = dailySummary.ToString

        txtReceipt.Text = order1.ToString

        ClearForm()


    End Sub

i am not sure if this is your peorblem , but should not you declear dailySummary outside
btnPlcOrder_Click code ??
what i understand that each time you place order a new instance of daily summary will creat , where you need only one where you will store all the orders for the day .

This article has been dead for over six months. Start a new discussion instead.