I want to get only prices value in the console application. So if the normal value of the price is more than 30 just deduct it to 10 percent. In the set method i had to put the condition if(value > 30), but i dont know the codes not working.
class Book
{
public string name;
public string writer;
public string publisher;
private double price;
public string category;
public Book(string name, string writer, string publisher, double price, string category)
{
this.name = name;
this.writer = writer;
this.publisher = publisher;
this.price = price;
this.category = category;
}
public double Price
{
get
{
return price;
}
set
{
if(value >= 30)
price = value * (.1);
}
}
}
class Program
{
static void Main(string[] args)
{
Book b = new Book("Book1", "Micheal", "AB Publisher", 21.50, "Thriller");
Book b1 = new Book("Book2", "Jones", "CD Publisher", 36.90, "History");
Console.WriteLine(b.Price);
Console.WriteLine(b1.Price);
}
}