Solved

now it is showing two errors.

Posted on 2008-09-30
3
196 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
What is MicroStrategy.NET? 2 47
C# remove trailing commas from csv file 10 52
dynamic menu in asp.net c# 11 31
C# Error - Add Failed 12 53
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This video discusses moving either the default database or any database to a new volume.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

743 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

12 Experts available now in Live!

Get 1:1 Help Now