Solved

now it is showing two errors.

Posted on 2008-09-30
3
197 Views
Last Modified: 2012-05-05
1) no overload for method 'FoodItem' takes 0 arguments.
2) Use of keyword base is not valid in this context
0
Comment
Question by:sarang8180
  • 2
3 Comments
 
LVL 5

Expert Comment

by:johnaryan
ID: 22604206
Could you add a snippet of your code.
Perhaps you have not defined a constructor with that accepts 2 parameters

John
0
 
LVL 14

Expert Comment

by:Binuth
ID: 22604211
Are you using same code posted by "oxyoo" ? if not use same code
    /// <summary>

    /// Summary description for FoodItem.

    /// </summary>

    public class FoodItem

    {

        private extern int Calories_Per_Gram = 9;

        private readonly int fatgrams;

        protected int servings;

 

        public FoodItem()

        {

        }

 

        public FoodItem(int Fatgrams1, int servings1)

        {

            fatgrams = Fatgrams1;

            servings = servings1;

        }

 

        private int Calories()

        {

            return fatgrams*Calories_Per_Gram;

        }

 

        public int CaloriesPerSavings()

        {

            return (Calories()/servings);

        }

    }

 

 

 

 

 

 

    /// <summary>

    /// Summary description for Pizza.

    /// </summary>

    public class Pizza : FoodItem

    {

        public Pizza(int fatGrams) : base(fatGrams, 8)

        {

        }

    }

Open in new window

0
 
LVL 5

Accepted Solution

by:
johnaryan earned 500 total points
ID: 22604234
I just tried that and it worked fine.
I used this to call the below:

static void Main(string[] args)
        {
             Pizza p = new Pizza(2);
        }
using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

namespace TestConsole

{

    /// <summary>

    /// Summary description for FoodItem.

    /// </summary>

    public class FoodItem

    {

        protected int Calories_Per_Gram = 9;

        private readonly int fatgrams;

        protected int servings;
 

        public FoodItem()

        {

        }
 

        public FoodItem(int Fatgrams1, int servings1)

        {

            fatgrams = Fatgrams1;

            servings = servings1;

        }
 

        private int Calories()

        {

            return fatgrams * Calories_Per_Gram;

        }
 

        public int CaloriesPerSavings()

        {

            return (Calories() / servings);

        }

    }
 

    /// <summary>

    /// Summary description for Pizza.

    /// </summary>

    public class Pizza : FoodItem

    {

        public Pizza(int fatGrams)

            : base(fatGrams, 8)

        {

        }

    }

}

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now