title: C# lower the price with get/set if the value is over x
body: <p>I need to use get and set commands to lower the price 10% if it's over 30. The price doesn't change and obviously there's something that I don't notice. The task requires to use property. Get must return price command's value. There was a tip to use if in set command.</p>
  
  <pre><code>using System;
  class Book
  {
  public string Name;
  public string Writer;
  public string publisher;
  private float price;
  public string genre;
  
  
  
  public Book(string Name, string Writer, string publisher, float price, string genre)
  {
      this.Name = Name;
      this.Writer = Writer;
      this.publisher = publisher;
      this.price = price;
      this.genre = genre;
  }    
  
  public float Price
  {
      get
      {
          return price;
      }
      set
      {
          if (value &gt; 30)
          {
              price = value *0.90f;                
          }
          else
          {
              price = value;
          }
      }
  }
  static void Main(string[] args)
  {
      Book b = new Book("First Book", "W. Writer", "publish company 1", 21.50f, "Crime");
      Book b2 = new Book("Second Book", "T. Typer", "publish company 2", 36.90f, "Fantasy");
      Console.WriteLine(b.price);
      Console.WriteLine(b2.Price);
  }}
  </code></pre>