Untitled
unknown
plain_text
3 years ago
1.9 kB
6
Indexable
Book book = new Book("Pride and prejudice", "Jane Austen");
Book book2 = new Book();
//book.isbn = "9780141439518";
//book.price = 9.5f;
//book.printInfo();
//book.printPrice();
//Console.WriteLine("-----------------------");
//book.printInfo("Jag gillar gröt");
//Console.WriteLine("-----------------------");
//book2.printInfo();
book.setIsbn("9780141439518");
book.setPrice(8.5f);
book.printInfo();
book.printPrice();
class Book
{
private string author;
string isbn;
string title;
float price;
public Book()
{
this.title = "-";
this.isbn = "-";
this.author = "-";
}
public Book(string title, string author)
{
this.title = title;
this.author = author;
this.isbn = "";
}
public string getAuthor()
{
return author;
}
public string getIsbn()
{
return this.isbn;
}
public void setIsbn(string isbn)
{
this.isbn = isbn;
}
public void setPrice(float price)
{
this.price = price;
}
public void printInfo()
{
Console.WriteLine("Book info: ");
Console.WriteLine("Title: " + this.title);
Console.WriteLine("Author: " + this.author);
Console.WriteLine("ISBN: " + this.isbn);
}
public void printInfo(string message)
{
Console.WriteLine("Book info: ");
Console.WriteLine("Title: " + this.title);
Console.WriteLine("Author: " + this.author);
Console.WriteLine("ISBN: " + this.isbn);
Console.WriteLine("With message: " + message);
}
public void printPrice()
{
Console.WriteLine("The price of the book is: " + this.price + " euro!");
}
}Editor is loading...