Solved

now it is showing two errors.

Posted on 2008-09-30
3
202 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

617 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