Method Argument Issues

No overload for method 'Calculate' takes '4' arguments

Page 1 of 1

4 Replies - 933 Views - Last Post: 08 April 2010 - 12:01 AM Rate Topic: -----

#1 mattiboi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 02-January 10

Method Argument Issues

Posted 06 April 2010 - 10:02 PM

I'm trying to write a method that calculates the rental total down to the Amount Due


Rental Total
Displays The DvD and Bluray
Subtotal

Is the total of the Rental Amount with the New Release but without the discount

Discount displays the %10

Amt Due is everything including the discount





I did some of the calculations

But the problem is I can't call the arguments with the Method and the compiler returns this error:

No overload for method 'Calculate' takes '4' arguments

Any Advice on how I could fix this Calculate method would be greatly appreciated.





// 
//Matt Iwan 
//CSC-236001 
// Movie Rental Program 2 
// Add A Store Summary and Rental Summary to calculate the  
// Amount Due Tax, After Discount Income and # of Customers Served 



using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace MattIwanRentalStore
{
    public partial class FrmMovieRental3 : Form
    {
        public FrmMovieRental3()
        {
            InitializeComponent();


        }









        //Constants 
        const double CDISCOUNT = .10d;
        const double CMOVDVD = 4.50;
        const double CMOVBD = 5.00d;
        const double CNEWRELEASE = 1.00d;
        //Variables 
        int vCustServd = 0;
        double vAmtDue;
        double vStoreIncome;
        double vRentalTotal;
        int vMovieQuant = 0;
        double vDiscount;
        //Project3 Variables 
        double vSubTotal;

        bool BDMovietype = true;
        bool Member = true;
        bool NewRelease = true;
        bool DVDMovietype = true;






        private void btnSubmit_Click(object sender, EventArgs e)
        {





            if (txtSearch.Text == string.Empty)
            {
                MessageBox.Show("You need to enter a movie title", "Missing Characters");

            }
            else
            {
                vMovieQuant += 1;
                lblMovieQuant.Text = vMovieQuant.ToString();
                MessageBox.Show("Request Accepted");


                txtSearch.Text = string.Empty;
            }



        }


        private void btnAbout_Click(object sender, EventArgs e)
        {
            MessageBox.Show("Matt Iwan CSC 236-001 Movie Rental Project");
        }

        private void btnExit_Click(object sender, EventArgs e)
        {
            this.Close();

        }

        int vcount = 0;


        private void counter(int vcount)
        {

            vcount += 1;


            if (vcount == 5)
            {
                MessageBox.Show("Congrats you are Customer # 5!");

            }



            if (vcount == 25)
            {
                MessageBox.Show("Your'e customer # 25!");

            }
        }



        private void btnCalculate_Click(object sender, EventArgs e)
        {
            Calculate(rbDVD.Checked, rbBluRay.Checked, cbIsMember.Checked, cbNewRelease.Checked);
        }

            private void Calculate(double CMOVDVD,
                               double CDISCOUNT,
                               double CMOVBD,
                               double CNEWRELEASE)
        
            {

               


            if (rbDVD.Checked == true)
                vRentalTotal = CMOVDVD;
            else if (rbBluRay.Checked == true)
                vRentalTotal = CMOVBD;
            if (cbIsMember.Checked == true)
                vAmtDue = vRentalTotal * .10;
            double vSubTotal = vRentalTotal + CNEWRELEASE;
            double vTotal = vAmtDue - vDiscount;

            //Display the rental fee.
            lblDiscount.Text = vAmtDue.ToString();
            lblSubTotal.Text = vSubTotal.ToString();
            lblTotal.Text = vTotal.ToString();

            //Display the order.
            lblRentalAmt.Text = vRentalTotal.ToString();



            // lblTotal.Text = vRentalTotal.ToString("C");

        }





        


        private void StoreIncome(double vStoreIncome)
        {

            vStoreIncome = vRentalTotal;

            lblStoreIncome.Text = vStoreIncome.ToString("C");
        }

        private void btnSumClear_Click(object sender, EventArgs e)
        {
            lblMovieQuant.Text = null;
            lblDiscount.Text = null;
            lblRentalAmt.Text = null;
            lblTotal.Text = null;
            lblStoreIncome.Text = null;
            lblTotCust.Text = null;
            lblSubTotal.Text = null;


        }







        

        private void btnOrdCom_Click(object sender, EventArgs e)
        {


            if (MessageBox.Show("Confirm", "Confirm") == DialogResult.OK)
            {

            }





            //If btnOrdCom is clicked then cbIsMember enabled and unchecked 
            if (cbIsMember.Enabled == false)
            {
                cbIsMember.Enabled = true;
                cbIsMember.Checked = false;

                lblMovieQuant.Text = null;
                lblDiscount.Text = null;
                lblRentalAmt.Text = null;
                lblTotal.Text = null;
                lblStoreIncome.Text = null;
                lblTotCust.Text = null;
                lblSubTotal.Text = null;
                txtSearch.Text = string.Empty;
                cbNewRelease.Checked = false;
                rbDVD.Checked = false;
                rbBluRay.Checked = false;

            }

        }

        private void BtnClrNxt_Click(object sender, EventArgs e)
        {

            txtSearch.Text = string.Empty;
            cbNewRelease.Checked = false;
            rbDVD.Checked = false;
            rbBluRay.Checked = false;
        }


    }
}





Is This A Good Question/Topic? 0
  • +

Replies To: Method Argument Issues

#2 n8wxs  Icon User is offline

  • --... ...-- -.. . -. ---.. .-- -..- ...
  • member icon

Reputation: 972
  • View blog
  • Posts: 3,878
  • Joined: 07-January 08

Re: Method Argument Issues

Posted 06 April 2010 - 11:05 PM

You are calling the method with the wrong arguments:

...
private void btnCalculate_Click(object sender, EventArgs e)
{
    Calculate(rbDVD.Checked, rbBluRay.Checked, cbIsMember.Checked, cbNewRelease.Checked);
}

private void Calculate(double CMOVDVD,
                   double CDISCOUNT,
                   double CMOVBD,
                   double CNEWRELEASE)
{
    if (rbDVD.Checked == true)
...



You are not calling it with doubles, but rather checkbox booleans.
Was This Post Helpful? 1
  • +
  • -

#3 mattiboi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 02-January 10

Re: Method Argument Issues

Posted 07 April 2010 - 11:27 AM

How would I manage to Call is using the Checkbox Boolean???

Am I missing code for it??? Or do I have the right Code but done wrong?

I just got Rid of A bunch of Checkbox and Radio Button "Checked Changed" events.

Those events made the program funky...

but now that those are gone How would I go about calling The booleans you speak of?
Was This Post Helpful? 0
  • +
  • -

#4 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1526
  • View blog
  • Posts: 5,961
  • Joined: 21-March 08

Re: Method Argument Issues

Posted 07 April 2010 - 11:42 AM

View Postmattiboi, on 07 April 2010 - 01:27 PM, said:

How would I manage to Call is using the Checkbox Boolean???

Am I missing code for it??? Or do I have the right Code but done wrong?

I just got Rid of A bunch of Checkbox and Radio Button "Checked Changed" events.

Those events made the program funky...

but now that those are gone How would I go about calling The booleans you speak of?


You don't need to pass them(unless this is a school project with the requirement to pass the boolean values as arguments). Since the controls are accessible by any event/method on the form, you don't need to pass the values. Simply access the control from the method...

private void Calculate()
{
    if (rbDVD.Checked)
    {

    }
    // and the rest of the if statements
}


Was This Post Helpful? 1
  • +
  • -

#5 mattiboi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 02-January 10

Re: Method Argument Issues

Posted 08 April 2010 - 12:01 AM

For sure,


Thanks...

I got it fixed now...

I didnt even need to pass the boolean like you said...


I kinda figured I had to but found out differently... That made things alot easier.



That and the bigger part of why my code was out of whack was also because there were stray curly braces...
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1