Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.IO;
- namespace practice
- {
- public abstract class First
- {
- public string name;
- public int ID;
- virtual public string Name { get {return name;} set { name = value; } }
- //abstract public void GetInfo () { }
- public static bool Compare(First a, First b)
- {
- return (a.name == b.name);
- }
- public First(string name)
- {
- this.name = name;
- }
- public First() { }
- }
- public class List_of_orgs
- {
- public List_of_orgs()
- {
- }
- public List<Organisation> org = new List<Organisation>();
- public void AddOrg(Organisation obj)
- {
- org.Add(obj);
- }
- public void RemoveOrg(Organisation obj)
- {
- int del_idx = -1;
- foreach (Organisation o in org)
- if (obj.name == o.name) del_idx = org.IndexOf(o);
- if (del_idx != -1) org.RemoveAt(del_idx);
- }
- public void GetCompanyVacInfo (string name)
- {
- foreach (Organisation o in org)
- if (name == o.name)
- {
- Console.WriteLine();
- o.GetInfo();
- o.GetVac();
- }
- }
- public void SearchBySpec (string spec)
- {
- foreach (Organisation o in org)
- {
- Console.WriteLine();
- o.GetVac(spec);
- }
- }
- public void ShowAllVac()
- {
- foreach (Organisation o in org)
- o.GetFullInfo();
- }
- }
- public class Organisation: First
- {
- public List<Vacancy> vac = new List<Vacancy>();
- public void AddVac(Vacancy obj)
- {
- vac.Add(obj);
- obj.company = name;
- }
- public void RemoveVac(Vacancy obj)
- {
- int del_idx = -1;
- foreach (Vacancy v in vac)
- if (obj.name == v.name) del_idx = vac.IndexOf(v);
- if (del_idx != -1) vac.RemoveAt(del_idx);
- }
- public string address;
- public string field;
- public Organisation (string name, string address, string field)
- {
- this.name = name;
- this. address = address;
- this.field = field;
- }
- public string Address
- {
- get { return address; }
- set { address = value; }
- }
- public string Field
- {
- get { return field; }
- set { field = value; }
- }
- public void GetInfo()
- {
- Console.WriteLine("Название: {0};\nАдрес: {1};\nОбласть деятельности: {2};", name, address, field);
- }
- public void GetFullInfo()
- {
- foreach (Vacancy v in vac)
- {
- Console.WriteLine();
- v.GetMoreInfo();
- }
- }
- public void GetVac()
- {
- foreach (Vacancy v in vac)
- {
- Console.WriteLine();
- v.GetInfo();
- }
- }
- public void GetVac(string spec)
- {
- foreach (Vacancy v in vac)
- if (v.specialization == spec) { Console.WriteLine(); v.GetInfo(); }
- }
- }
- public class Vacancy: First
- {
- public string specialization;
- public double salary;
- public string schedule;
- public string company;
- public Vacancy (string name, string specialization, double salary, string schedule)
- {
- this.name = name;
- this.specialization = specialization;
- this.salary = salary;
- this.schedule = schedule;
- }
- public Vacancy () { }
- public string Specialization
- {
- get { return specialization; }
- set { specialization = value; }
- }
- public double Salary
- {
- get { return salary; }
- set { salary = value; }
- }
- public string Schedule
- {
- get { return schedule; }
- set { schedule = value; }
- }
- public void GetInfo()
- {
- Console.WriteLine("Должность: {0};\nСпециальность: {1};\nЗарплата: {2};\nГрафик: {3}.", name, specialization, salary, schedule);
- }
- public void GetMoreInfo()
- {
- Console.WriteLine("Компания: {0};\nДолжность: {1};\nСпециальность: {2};\nЗарплата: {3};\nГрафик: {4}.", company, name, specialization, salary, schedule);
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- List_of_orgs l = new List_of_orgs();
- Organisation one = new Organisation("Ростелеком", "Саратов", "Связь");
- l.AddOrg(one);
- one.AddVac(new Vacancy("Директор", "Менеджемент", 10000, "пятидневный"));
- Organisation two = new Organisation("Магнит", "Саратов", "Торговля");
- l.AddOrg(two);
- two.AddVac(new Vacancy("Кассир", "Обслуживание", 1000, "пятидневный с неполным рабочим днём"));
- two.AddVac(new Vacancy("Кассир", "Обслуживание", 2000, "пятидневный"));
- two.AddVac(new Vacancy("Охранник", "Охрана", 3000, "сменный"));
- Organisation three = new Organisation("Сбербанк", "Саратов", "Финансы");
- l.AddOrg(three);
- three.AddVac(new Vacancy("Консультант", "Обслуживание", 4000, "пятидневный"));
- Organisation four = new Organisation("Яблонька", "Саратов", "Общественное питание");
- l.AddOrg(four);
- four.AddVac(new Vacancy("Пекарь", "Изготовление продуктов питания", 3500, "сменным"));
- four.AddVac(new Vacancy("Продавец", "Обслуживание", 2000, "пятидневный"));
- Console.WriteLine("Список доступных вакансий\n");
- l.ShowAllVac();
- l.RemoveOrg(l.org[2]);
- l.org[1].RemoveVac(l.org[1].vac[1]);
- Console.WriteLine("\n\nВакансии в компании Яблонька\n");
- l.GetCompanyVacInfo("Яблонька");
- Console.WriteLine("\n\nВакансии по специальности обслуживание\n");
- l.SearchBySpec("Обслуживание");
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement