ss_blog_claim=764af2e4183cd5f1aff30b9e7db87aa1

Sean

July 21, 2008

using System;
using System.Collections.Generic;
using System.Text;

public class Book
{
public enum BookType
{
Undefined,
Fiction,
NonFiction,
History,
Science
}
public enum StatusType
{
Undefined,
Available,
Borrowed
}

private string author;
private BookType bookType;
private int pages;
private StatusType status;
private string title;

public Book()
{
this.title = “”;
this.author = “”;
this.status = StatusType.Available;
}

public Book(BookType type, string title, string author)
{
this.title = “”;
this.author = “”;
this.status = StatusType.Available;
this.bookType = type;
this.title = title;
this.author = author;
}

public void Borrow()
{
if (this.status == StatusType.Available)
{
this.status = StatusType.Borrowed;
}
else
{
Console.WriteLine(”Book is already borrowed”);
}
}

public void Return()
{
if (this.status == StatusType.Borrowed)
{
this.status = StatusType.Available;
}
else
{
Console.WriteLine(”Book is currently available”);
}
}

public override string ToString()
{
return string.Format(”Type: {0}, Title: {1}, Author: {2}, Pages: {3}”, new object[] { this.Type, this.Title, this.Author, this.Pages });
}

public string Author
{
get
{
if (this.author.Length < = 0)
{
return "Unknown";
}
return this.author;
}
set
{
if (!new System.Text.RegularExpressions.Regex(@"\d").IsMatch(value))
{
this.author = value;
}
}
}

public bool IsBorrowed
{
get
{
return (this.status == StatusType.Borrowed);
}
}

public int Pages
{
get
{
return this.pages;
}
set
{
this.pages = value;
}
}

public string Title
{
get
{
return this.title;
}
set
{
this.title = value;
}
}

public BookType Type
{
get
{
return this.bookType;
}
set
{
this.bookType = value;
}
}

public string Value
{
get
{
return string.Format("Type: {0}, Title: {1}, Author: {2}, Pages: {3}", new object[] { this.Type, this.Title, this.Author, this.Pages });
}
}
}

Comments »

The URI to TrackBack this entry is: http://uber.blogsome.com/2008/07/21/sean/trackback/

No comments yet.

RSS feed for comments on this post.

Leave a comment

Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>



Anti-spam measure: please retype the above text into the box provided.