Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.IO;
- namespace Ulyanov_Abstract
- {
- abstract class Person
- {
- public string Name;
- public int Birthdate;
- public string Faculty;
- public char Attach;
- abstract protected void print();
- abstract protected int getAge();
- protected bool CompareTo(ref Person arg1, ref Person arg2)
- {
- return arg1.Birthdate < arg2.Birthdate;
- }
- static public Person[] readFromFile(string inputFileName)
- {
- FileStream inputFile = new FileStream(inputFileName, FileMode.Open, FileAccess.Read);
- StreamReader inputReader = new StreamReader(inputFile);
- Int32 allocCnt = 0;
- while (inputReader.ReadLine() != null)
- {
- inputReader.ReadLine();
- inputReader.ReadLine();
- inputReader.ReadLine();
- inputReader.ReadLine();
- inputReader.ReadLine();
- allocCnt++;
- }
- Person[] arrPtr = new Person[allocCnt];
- string[] buff = new string[2];
- inputFile.Seek(0, SeekOrigin.Begin);
- for(Int32 i = 0; i < allocCnt; i++)
- {
- arrPtr[i].Name = inputReader.ReadLine();
- arrPtr[i].Birthdate = Convert.ToInt32(inputReader.ReadLine());
- arrPtr[i].Faculty = inputReader.ReadLine();
- buff[0] = inputReader.ReadLine();
- if( (buff[1] = inputReader.ReadLine() )
- != "n/a")
- {
- ((Teacher)arrPtr[i]).Position = buff[0];
- ((Teacher)arrPtr[i]).Expierence = buff[1];
- arrPtr[i].Attach = 'T';
- }
- else if( (buff[0] = inputReader.ReadLine())
- != "n/a")
- {
- ((Student)arrPtr[i]).Course = buff[0];
- arrPtr[i].Attach = 'S';
- }
- else
- {
- arrPtr[i].Attach = 'A';
- }
- }
- inputFile.Close();
- return arrPtr;
- }
- }
- class Teacher : Person
- {
- public string Position;
- public string Expierence;
- override protected void print()
- {
- }
- override protected int getAge()
- {
- return 0;
- }
- }
- class Applicant : Person
- {
- override protected void print()
- {
- }
- override protected int getAge()
- {
- return 0;
- }
- }
- class Student : Person
- {
- public string Course;
- override protected void print()
- {
- }
- override protected int getAge()
- {
- return 0;
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- Person.readFromFile("source.txt");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement