コード例 #1
0
ファイル: Earth.cs プロジェクト: nastyafedoseeva2000/OOP
 public static Earth Instance()
 {
     if (instance == null)
     {
         instance = new Earth();
     }
     return(instance);
 }
コード例 #2
0
        static void Main(string[] args)
        {
            Earth ourOneAndOnlyEarth  = Earth.Instance;
            Earth theSameBigBlueEarth = Earth.Instance;

            ourOneAndOnlyEarth.CountHumanPopulationFromSatelliteData();

            System.Console.WriteLine($"Are Equal: {ourOneAndOnlyEarth.Equals(theSameBigBlueEarth)}");

            // Same earth, same population
            System.Console.WriteLine(ourOneAndOnlyEarth.GetHumanPopulationFromSatelliteData());
            System.Console.WriteLine(theSameBigBlueEarth.GetHumanPopulationFromSatelliteData());
        }