type or namespace name cannot be found

Hello

using UnityEngine;
using System.Collections.Generic;
using System.Collections;

public class newgame : MonoBehaviour {
       
    // creates a random degree for each planet
    public int degreegenerator ()
        {
            int generateddegree;
            generateddegree = Random.Range (0, 30);
            return generateddegree;
        }
           
    // creates a random element for each planet
    public string elementgenerator()
        {
            Dictionary<int, string> elementdictionary = new Dictionary<int, string>()
            {{1, "fire"}, {2, "earth"}, {3, "air"}, {4, "water"}};

            int elementnumber = Random.Range(1, 5);

            return elementdictionary[elementnumber];
        }

    // creates a random mode for each planet
    public string modegenerator ()
        {
            string[] modes = { "cardinal", "fixed", "mutable" };

            string mode = modes [Random.Range (0, modes.Length)];
            return mode;
        }

    // placing the generated mode, degree, element in planet
    class planet
    {
        elementgenerator planetelement = new elementgenerator ();
        degreegenerator planetdegree = new degreegenerator ();
        modegenerator planetmode = new modegenerator ();
    }
       
    // adding different planets into a list
    void planetgen ()
    {
        List<planet> planetslist = new List<planet>();

        planet sun = new planet ();
        planetslist.Add (sun);
        planet moon = new planet ();
        planetslist.Add (moon);
        planet mercury = new planet ();
        planetslist.Add (mercury);
        planet venus = new planet ();
        planetslist.Add (venus);
        planet mars = new planet ();
        planetslist.Add (mars);
        planet jupiter = new planet ();
        planetslist.Add (jupiter);
        planet saturn = new planet ();
        planetslist.Add (saturn);
    }
}

Monodevelop says: The type or namespace name ‘elementgenerator’ could not be found. The type or namespace name ‘modegenerator’ could not be found. The type or namespace name ‘degreegenerator’ could not be found.

below code is the problem.

class planet
    {
        elementgenerator planetelement = new elementgenerator ();
        degreegenerator planetdegree = new degreegenerator ();
        modegenerator planetmode = new modegenerator ();
    }

Please help me thanks:(

Well, it’s right. You’re trying to use each of these things as a type (both by declaring fields of that type, and by using them with “new”). But they’re not types. They’re methods in the newgame class.

What is it you’re trying to do here?

Whatever it is, I might recommend spending some time working through learncs.org. If books are more your thing, there are many good introductory C# books available at your favorite bookseller.

This is indeed programming 101. Go to the learn section. Watch the videos in the scripting section from the beginning.

My best guess is that the system should look like this.

    // placing the generated mode, degree, element in planet
    class Planet
    {
        string planetelement;
        int planetdegree;
        string planetmode;

        public Planet (){        
            string planetelement = ElementGenerator();
            int planetdegree = DegreeGenerator();
            string planetmode = ElementGenerator();
        }

    // creates a random degree for each planet
    public int DegreeGenerator ()
        {
            int generateddegree;
            generateddegree = Random.Range (0, 30);
            return generateddegree;
        }
          
    // creates a random element for each planet
    public string ElementGenerator()
        {
            Dictionary<int, string> elementdictionary = new Dictionary<int, string>()
            {{1, "fire"}, {2, "earth"}, {3, "air"}, {4, "water"}};

            int elementnumber = Random.Range(1, 5);

            return elementdictionary[elementnumber];
        }

    // creates a random mode for each planet
    public string ModeGenerator ()
        {
            string[] modes = { "cardinal", "fixed", "mutable" };

            string mode = modes [Random.Range (0, modes.Length)];
            return mode;
        }
    }

class NewGame : MonoBehaviour {
    // adding different planets into a list
    void planetgen ()
    {
        List<planet> planetsList = new List<planet>();
        for (int i = 0; i < 10; i++){
            planetList.Add(new Planet());
        }
    }
}