-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathAbstract_Class.cs
More file actions
47 lines (42 loc) · 1 KB
/
Abstract_Class.cs
File metadata and controls
47 lines (42 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using System;
using System.Collections.Generic;
using System.IO;
abstract class Book
{
protected String title;
protected String author;
public Book(String t, String a)
{
title = t;
author = a;
}
public abstract void display();
}
class MyBook : Book
{
int bk_price;
public MyBook(string t, string a, int price) : base(t,a)
{
base.title = t;
base.author =a;
this.bk_price = price;
}
public override void display()
{
Console.WriteLine("Title: {0}", title);
Console.WriteLine("Author: {0}", author);
Console.WriteLine("Price: {0}", bk_price);
}
}
//Write MyBook class
class Solution
{
static void Main(String[] args)
{
String title = Console.ReadLine();
String author = Console.ReadLine();
int price = Int32.Parse(Console.ReadLine());
Book new_novel = new MyBook(title, author, price);
new_novel.display();
}
}