Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Programming in C#: Create a base class titled ReadingMaterial. Include subclasse

ID: 3700269 • Letter: P

Question

Programming in C#: Create a base class titled ReadingMaterial. Include subclasses of Online, Book, and Magazine. Design your classes so that common characteristics are placed within the ReadingMaterial class. Provide the unique characteristics of the subclasses in the derived classes. Define an interface called IPrintable that has a method that returns as a string how it is available in hard copy form (ie., printable PDF, from a publisher or from a bookstore). Include a presentation class to test your design.

Explanation / Answer

using System;

interface IPrintable
{
string available();
}
class ReadingMaterial // base class
{
private string authorName;
private string title;
private double cost;

public ReadingMaterial(string authorName,string title,double cost)//constructor
{
this.authorName = authorName;
this.title = title;
this.cost = cost;
}
public override string ToString()
{
return "Title : "+title+ " Author : "+authorName +" Cost : $"+cost;
}
}
class Online :ReadingMaterial,IPrintable
{
private string website;
// send arguments to base class constructor
public Online(string authorName,string title,double cost,string website): base(authorName,title,cost)
{
this.website = website;
}
public string available() // implement interface method
{
  return "Printable PDF";
}
public override string ToString()
{
return base.ToString()+" Website : "+website + " Availabilty : "+ available();
}
}
class Book : ReadingMaterial,IPrintable
{
private string isbn;
// send arguments to base class constructor
public Book(string authorName,string title,double cost,string isbn):base(authorName,title,cost)
{
this.isbn = isbn;
}
public string available()// implement interface method
{
  return "from the publisher or from a book store";
}
public override string ToString()
{

return base.ToString()+" ISBN : "+isbn + " Availabilty : "+ available();
}
}
class Magazine : ReadingMaterial,IPrintable
{
private string date;
// send arguments to base class constructor
public Magazine(string authorName,string title,double cost,string date): base(authorName,title,cost)
{
this.date = date;
}
public string available()// implement interface method
{
  return "from the publisher or from a book store";
}
public override string ToString()
{
return base.ToString()+" Publish Date : "+date + " Availabilty : "+ available();
}
}
public class Presentation
{
public static void Main()
{
Online o = new Online("J. W. Carry","NY Daily",0.00,"nydaily.edu");
Console.WriteLine(o.ToString());

Book b = new Book("fritz Onion","Essentia ASP.NET",250.50,"46576868");
Console.WriteLine(b.ToString());

Magazine m = new Magazine(" A. Johnson","PC Magazine",30.67,"November 2017");
Console.WriteLine(m.ToString());

}
}

Output:

Title : NY Daily Author : J. W. Carry Cost : $0 Website : nydaily.edu Availabilty : Printable PDF
Title : Essentia ASP.NET Author : fritz Onion Cost : $250.5 ISBN : 46576868 Availabilty : from the publisher or from a book store
Title : PC Magazine Author : A. Johnson Cost : $30.67 Publish Date : November 2017 Availabilty : from the publisher or from a book store

Do ask if any doubt. Please upvote.