Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace Drafty
- {
- class Program
- {
- class Continent
- {
- public string Name { get; set; }
- public double square { get; set; }
- public Continent(string name, double square = 1000)
- {
- this.Name = name;
- this.square = square;
- }
- public void GetInfo()
- {
- Console.WriteLine($"Continent name: {this.Name}, square: {this.square}");
- }
- }
- class Ocean
- {
- public string Name { get; set; }
- }
- class Island
- {
- public string Name { get; set; }
- public int Population { get; set; }
- }
- class Planet
- {
- List<Continent> conCount;
- public string Name { get; private set; }
- public Planet(string name, int continentsCount)
- {
- this.Name = name;
- this.conCount = new List<Continent>();
- for (int i=0; i<continentsCount; i++)
- {
- AddContinent("какой-то континент");
- }
- }
- public void GetInfo()
- {
- Console.WriteLine($"Планета: {this.Name}, количество материков: {this.conCount.Count}");
- }
- public void AddContinent(string name, double square = 1000)
- {
- this.conCount.Add(new Continent(name, square));
- }
- public void AddContinent(params string[] name)
- {
- for (int i=0; i<name.Length; i++)
- {
- this.conCount.Add(new Continent(name[i]));
- }
- }
- public void GetContinentName(int index)
- {
- if (index >= this.conCount.Count || index < 0)
- {
- Console.WriteLine("Такого континента нет");
- return;
- }
- Console.WriteLine($"Континент: {this.conCount[index].Name}");
- }
- }
- static void Main(string[] args)
- {
- Planet earth = new Planet("earth", 0);
- earth.AddContinent("Asia", "Africa", "North America", "South America", "Antarctida", "Europe", "Australia");
- earth.GetContinentName(2);
- earth.GetInfo();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement