Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace OBJECTORIENTATEDCODE
- {
- class Program
- {
- static void Main(string[] args)
- {
- Book potter = new Book()
- {
- author = "JK Rowling",
- title = "Harry Potter and the Philosiphers stone",
- Numpages = 223,
- Cost = 4.99
- };
- potter.display();
- potter.Discount();
- }
- }
- class Book
- {
- public string author;
- public string title;
- public int Numpages;
- public double Cost;
- public void display()
- {
- Console.WriteLine("Author " + this.author);
- Console.WriteLine("Title " + this.title);
- Console.WriteLine("Number of pages " + this.Numpages);
- Console.WriteLine("Cost £ " + this.Cost);
- }
- public void Discount()
- {
- Console.WriteLine(this.Cost * 0.9);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement