forked from Anthonymcqueen21/HackerRank-2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSolution.java
34 lines (31 loc) · 807 Bytes
/
Solution.java
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
//Problem:
//Java 8
// Declare your class here. Do not use the 'public' access modifier.
// Declare the price instance variable
class MyBook extends Book{
int price;
/**
* Class Constructor
*
* @param title The book's title.
* @param author The book's author.
* @param price The book's price.
**/
// Write your constructor here
MyBook(String title, String author, int price)
{
super(title, author);
this.price = price;
}
/**
* Method Name: display
*
* Print the title, author, and price in the specified format.
**/
// Write your method here
@Override
void display(){
System.out.println("Title: "+title+"\nAuthor: "+author+"\nPrice: "+price);
}
}
// End class