I suggest you...

please healp

please help me
i make excercise 5.1 and i have that error:
"You must call the base class, passing in the correct number of protons and electrons."
i don't know what is wrong, my code:

public class Hydrogen:Atom{

public Hydrogen() : base(0,0) { }
}

please help me...
sorry for my english. i learn...

12 votes
Vote
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    I agree to the terms of service
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    Anonymous shared this idea  ·   ·  Admin →

    7 comments

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      I agree to the terms of service
      Signed in as (Sign out)
      Submitting...
      • spiridon konofaosspiridon konofaos commented  · 

        Thanks for this answer. Initially, I had:
        public Hydrogen() : base("hydrogen") {}

        Example before should have been more clear about what you could do with a base();

        base() makes so much more sense now.

      • Parsifal PiraniParsifal Pirani commented  · 

        I put this answer : (public Hydrogen() : base(1,1)) 6 or 7 months ago but compiler said to fix error etc.
        Now I come back re-click verfy and compiler says Well Done ! something has been fixed

      • Stephen VerbistStephen Verbist commented  · 

        You just have to inherit the base with 1 electron and 1 proton. Like so
        public class Hydrogen : Atom
        {
        public Hydrogen() : base(1,1)
        {
        }
        }

        This because a hydrogen atom actually has 1 electron and 1 proton.

      • MichelleMichelle commented  · 

        I had the error you must define a parameterless constructor; here is the code that I had, thinking that I followed the guidance correcltly:

        public class Atom
        {
        public Atom(int protons, int electrons)
        {
        Protons = protons;
        Electrons = electrons;
        }

        public int Protons { get; set; }

        public int Electrons { get; set; }


        }

        public class Hydrogen : Atom
        {
        public Hydrogen(int protons, int electrons) : base(protons, electrons)
        {
        }
        }

        public class Program
        {
        public static void Main()
        {

        }
        }

        However after many attempts at trying to get this right, I finally solved the problem using the below code:

        public class Atom
        {
        public Atom(int protons, int electrons)
        {
        Protons = protons;
        Electrons = electrons;
        }

        public int Protons { get; set; }

        public int Electrons { get; set; }


        }

        public class Hydrogen : Atom
        {
        public Hydrogen() : base(1, 1)
        {
        }
        }

        public class Program
        {
        public static void Main()
        {

        }
        }

        I hope this helps :)

      • Anonymous commented  · 

        it works, because you wrote the real numbers of Protons and Electrons for Hydrogen - 1, 1

      • Anonymous commented  · 

        the whole 5.1 thing is a total mess, barely anything is explained and the errors are not helping a lot

        this is my answer after way too many tries, whats the explanation? I don't know but it works

        public class Atom
        {

        public Atom(){}
        public Atom (int protons, int electrons)
        {
        Protons = protons;
        Electrons = electrons;
        }
        public int Protons { get; set; }
        public int Electrons { get; set; }
        }

        public class Hydrogen : Atom
        {
        public Hydrogen() : base(1,1)
        {

        }
        }
        public class Program
        {
        public static void Main()
        {

        }
        }

      • Courtney FayCourtney Fay commented  · 

        I am having same issue, but attempted differently. Did you figure this out?

        public class Atom
        {

        public int Protons { get; set; }

        public int Electrons { get; set; }

        public void Nucleus(int protons , int electrons)
        {
        protons = Protons;
        electrons = Electrons;
        }
        }

        public class Program
        {
        public static void Main()
        {
        var Hydrogen = new Atom();
        Hydrogen.Nucleus(1,2);
        }
        }

        my error says: Not all requirements have been met.

        "You must define a constructor with two integer parameters named protons and electrons"

        but I thought I did that. :-(

        No help or hints to guide you. Anyone?

      Feedback and Knowledge Base