using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
namespace OOPLib
{
class Library
{
}
class Person
{
public string PersonName;
public string PersonAddress;
public string PersonEmailAddress;
public Boolean PersonIsMale;
public DateTime PersonBirthDate;
//contructor of person class
public Person(string Name, string Adr, string Email, Boolean IsMale, DateTime BirthDate)
{
this.PersonName = Name;
this.PersonAddress = Adr;
this.PersonBirthDate = BirthDate;
this.PersonEmailAddress = Email;
this.PersonIsMale = IsMale;
}
public Person()
{
}
}//
//Author Class is derived from Person
class Author:Person
{
Weblinks AuthorWebs;
//constructor for author class
Author(Person p,Weblinks links)
{
this.PersonEmailAddress = p.PersonEmailAddress;
this.AuthorWebs = links;
this.PersonName = p.PersonName;
this.PersonAddress = p.PersonAddress;
this.PersonBirthDate = p.PersonBirthDate;
this.PersonIsMale = p.PersonIsMale;
}
}//
//List based collection of author objects
class Authors : CollectionBase
{
public void Add(Author newAuthor)
{
List.Add(newAuthor);
}
public void Remove(Author newAuthor)
{
List.Remove(newAuthor);
}
public Author this[int AuthorIndex]
{
get
{
return (Author)List[AuthorIndex];
}
set
{
List[AuthorIndex] = value;
}
}
}//
public class PrintedMedia
{
public string Id;
public string Name;
public long Price;
public string Publisher;
//constructor of PrintMedia Class
public PrintedMedia (string id,string name,long price ,string publisher)
{
this.Id = id;
this.Name = name;
this.Price = price;
this.Publisher = publisher;
}
//Default constructor
public PrintedMedia()
{
}
}//
//Book Class derived from PrintedMedia
class Book:PrintedMedia
{
string BookISBN;
Authors BookAuthors;
int BookCopies;
string BookEdition;
string BookCatagory;
Weblinks BookWebRef;
//constructor of book class
public Book(string ISBN, Authors newAuthors, int Copies, string Edition, string Catagory,Weblinks webref)
{
this.BookAuthors = newAuthors;
this.BookCatagory = Catagory;
this.BookCopies = Copies;
this.BookEdition = Edition;
this.BookISBN = ISBN;
this.BookWebRef = webref;
}
public Book()
{
}
}//
public enum PeriodicalTypes
{
Weekly,BiWeekly,Monthly,BiMonthly,SixMonthly,Yearly
}
//Periodical class inherit from PrintedMedia Class
class Periodical : PrintedMedia
{
PeriodicalTypes PeriodicalType;
DateTime PeriodicalIssueDate;
Periodical(PrintedMedia p,PeriodicalTypes q,DateTime IssueDate)
{
this.Id = p.Id;
this.Name = p.Name;
this.Price = p.Price;
this.Publisher = p.Publisher;
this.PeriodicalType = q;
this.PeriodicalIssueDate = IssueDate;
}
}//
//List Based Collection class for Periodicals
class Periodicals : CollectionBase
{
public void Add(Periodical newPeriodical)
{
List.Add(newPeriodical);
}
public void Remove(Periodical newPeriodical)
{
List.Remove(newPeriodical);
}
public Periodical this[int PeriodicalIndex]
{
get
{
return (Periodical)List[PeriodicalIndex];
}
set
{
List[PeriodicalIndex] = value;
}
}
}
//List Based Collection Class for Book's Web References
class Weblinks:CollectionBase
{
public void Add(string newUrl)
{
List.Add(newUrl);
}
public void Remove(string newUrl)
{
List.Remove(newUrl);
}
public string this[int WebIndex]
{
get
{
return (string)List[WebIndex];
}
set
{
List[WebIndex]=value;
}
}
}//
//List Based Book object collection
class Books : CollectionBase
{
public void Add(Book newBook)
{
List.Add(newBook);
}
public void Remove(Book newBook)
{
List.Remove(newBook);
}
public Book this[int BookIndex]
{
get
{
return (Book)List[BookIndex];
}
set
{
List[BookIndex] = value;
}
}
}//
//Member class derived from person class
class Member : Person
{
string MemberID;
long MemberDeposite;
Books BorrowedBooks;
Periodicals BorrowedPeriodicals;
Member(string ID, long Deposite, Person p,Books Borrowed,Periodicals Periodicals)
{
this.MemberID = ID;
this.MemberDeposite = Deposite;
this.PersonName = p.PersonName;
this.PersonAddress = p.PersonAddress;
this.PersonBirthDate = p.PersonBirthDate;
this.PersonEmailAddress = p.PersonEmailAddress;
this.PersonIsMale = p.PersonIsMale;
this.BorrowedBooks = Borrowed;
this.BorrowedPeriodicals = Periodicals;
}
}//
//List Based Collection of Member Objects
class Members : CollectionBase
{
public void Add(Member newMember)
{
List.Add(newMember);
}
public void Remove(Member newMember)
{
List.Remove(newMember);
}
public Member this[int MemberIndex]
{
get
{
return (Member)List[MemberIndex];
}
set
{
List[MemberIndex] = value;
}
}
public enum StaffPositions
{
Librarian, DeputyLibrarian, Clerk, Peon
}
public class StaffMember : Person
{
StaffPositions staffType;
StaffMember(Person p, StaffPositions q)
{
this.PersonAddress = p.PersonAddress;
this.PersonBirthDate = p.PersonBirthDate;
this.PersonEmailAddress = p.PersonEmailAddress;
this.PersonIsMale = p.PersonIsMale;
this.PersonName = p.PersonName;
staffType = q;
}
}//
//List Based collection of StaffMember objects
class StaffMembers : CollectionBase
{
public void Add(StaffMember newMember)
{
List.Add(newMember);
}
public void Remove(StaffMember newMember)
{
List.Remove(newMember);
}
public StaffMember this[int MemberIndex]
{
get
{
return (StaffMember)List[MemberIndex];
}
set
{
List[MemberIndex] = value;
}
}
}
}
}
No comments:
Post a Comment