Files

33 lines
805 B
Java
Raw Permalink Normal View History

2017-02-24 00:24:47 -06:00
// Author: Rodney Shaghoulian
2018-07-27 16:45:56 -07:00
// Github: github.com/RodneyShag
// HackerRank: hackerrank.com/RodneyShag
2017-02-24 00:24:47 -06:00
import java.util.*;
abstract class Book {
String title;
abstract void setTitle(String s);
String getTitle() {
return title;
}
}
class MyBook extends Book {
2017-03-24 00:02:30 -05:00
@Override
2017-02-24 00:24:47 -06:00
void setTitle(String s) {
title = s;
}
}
2017-03-24 00:02:30 -05:00
2017-02-24 00:24:47 -06:00
public class Main {
public static void main(String []args) {
2017-04-05 18:42:35 -05:00
// Book new_novel=new Book(); This line prHMain.java:25: error: Book is abstract; cannot be instantiated
2017-02-24 00:24:47 -06:00
Scanner sc = new Scanner(System.in);
String title = sc.nextLine();
MyBook new_novel = new MyBook();
new_novel.setTitle(title);
2017-04-05 18:42:35 -05:00
System.out.println("The title is: " + new_novel.getTitle());
2017-02-24 00:24:47 -06:00
sc.close();
}
}