Struct
using System;
public struct Book
{
public string title;
public string category;
public string author;
public int numPages;
public int currentPage;
public double ISBN;
public string coverStyle;
public Book(string title, string category, string author, int numPages, int currentPage, double isbn, string cover)
{
this.title = title;
this.category = category;
this.author = author;
this.numPages = numPages;
this.currentPage = currentPage;
this.ISBN = isbn;
this.coverStyle = cover;
}
public void nextPage()
{
if (this.currentPage != this.numPages)
{
this.currentPage++;
Console.WriteLine("Current page is now: " + this.currentPage);
}
else
{
Console.WriteLine("At end of book.");
}
}
public void prevPage()
{
if (this.currentPage != 1)
{
this.currentPage--;
Console.WriteLine("Current page is now: " + this.currentPage);
}
else
{
Console.WriteLine("At the beginning of the book.");
}
}
}
public class Program
{
public static void Main()
{
Book myBook = new Book("MCSD Certification Toolkit (Exam 70-483)", "Certification", "Covaci, Tiberiu", 648, 1, 81118612095, "Soft Cover");
Console.WriteLine(myBook.title);
Console.WriteLine(myBook.category);
Console.WriteLine(myBook.author);
Console.WriteLine(myBook.numPages);
Console.WriteLine(myBook.currentPage);
Console.WriteLine(myBook.ISBN);
Console.WriteLine(myBook.coverStyle);
myBook.nextPage();
myBook.prevPage();
}
}