Here is the processed document with the code blocks restored and formatted:
How to Create the Class Book with the following attributes: Book ID, Title, Authors, Unit Price and print the current details of the book. Add a behavior to modify the price and display the updated book details. Display the total Amount to be paid for each Book, using unit price & 12% tax. Implement using OO concepts in c#
Answer
using System;
using System.Collections.Generic;
namespace _94235 {
// Class Author
public class Author {
public string Name { get; set; }
}
// Class Book
public class Book {
private double Tax = 0.12;
public int ID { get; set; }
public string Title { get; set; }
public ICollection<Author> Authors { get; set; }
public double Price { get; set; }
public Book(int ID, string Title, ICollection<Author> Authors, double Price) {
this.ID = ID;
this.Title = Title;
this.Authors = Authors;
this.Price = Price;
}
// Calculate total Amount with 12% tax
public double CalculatePrice() {
return Price * (1 + Tax);
}
}
class Program {
static void Main(string[] args) {
// Init list of authors
List<Author> authors = new List<Author>() { new Author { Name = "1" }, new Author { Name = "2" }, new Author { Name = "3" } };
// Create new book
Book book = new Book(1,"a",authors,12);
// Change price
book.Price = 15.1;
// Show total Amount with 12% tax
Console.WriteLine(book.CalculatePrice());
}
}
}http://www.AssignmentExpert.com/