I am trying to build a class hierarchy (the Main constructor is called from Main, which, depending on some parameters, calls one of three subclasses.) The compiler generates an error "***" does not contain a constructor that takes arguments "and" member names cannot match the types in which they are contained. " How can I fix this?
Call base class
var Price=new Edition(EditionType, PagesNumber, PrintType);
Base class itself
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace PriceCalculator { public class Edition { private readonly int EditionType; private readonly int PagesNumber; private readonly int PrintType; public Edition(int EditionType, int PagesNumber, int PrintType) { this.EditionType = EditionType; this.PagesNumber = PagesNumber; this.PrintType = PrintType; int ApproxPrice = PagesNumber * PrintType; Calculate(ApproxPrice); } public int Calculate (int Price) { if (EditionType == 1) { int value = Convert.ToInt32(new Journal(Price)); return value; } else { return 0; } } } }
Journal class
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace PriceCalculator { public class Journal : Edition { private readonly int ApproxPrice; public Journal(int ApproxPrice) { this.ApproxPrice = ApproxPrice; ControlPrice(ApproxPrice); } public int ControlPrice(int Price) { Console.WriteLine("Test"); var mult = Convert.ToInt32(Console.Read()); return Convert.ToInt32(ApproxPrice * mult); } } }
public int Journal(int ApproxPrice)
are you trying to return a value in the constructor? - LLENN