-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstream.java
More file actions
81 lines (67 loc) · 1.48 KB
/
stream.java
File metadata and controls
81 lines (67 loc) · 1.48 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
abstract class Media
{
private String title;
private int duration;
protected boolean isPremium;
Media(String t, int d)
{
title = t;
duration = d;
}
void getDetails()
{
System.out.println("Title: " + title);
System.out.println("Duration: " + duration);
}
abstract void playContent();
}
class Movie extends Media
{
Movie(String t, int d, boolean s)
{
super(t,d);
isPremium = s;
}
void playContent()
{
if(isPremium == true)
{
System.out.println("Verifiying Subscription...");
System.out.println("Now playing:");
playContent();
}
else
{
System.out.println("Now playing:");
playContent();
}
}
}
class Podcast extends Media
{
Podcast(String t, int d)
{
super(t,d);
}
void playContent()
{
System.out.println("Playing ad...");
System.out.println("Now playing:");
getDetails();
}
}
public class stream
{
public static void main(String[] args)
{
//1
Media mov1 = new Movie("Inception", 148, true);
mov1.playContent();
//2
Media pod = new Podcast("Tech Talk", 30);
pod.playContent();
//3
Media mov2 = new Movie("Free Guy", 115, false);
mov2.playContent();
}
}