0% found this document useful (0 votes)
3 views9 pages

Java Social Scheduler OOP Design

The document outlines the design and implementation of a console-based Social Scheduler in Java, featuring classes for User, Channel, Post, and SchedulerService. It demonstrates OOP concepts such as inheritance, method overloading, method overriding, polymorphism, and encapsulation. The main class, SchedulerAppMain, tests the functionality by adding users and channels, creating and scheduling posts, and listing their statuses.

Uploaded by

mehulmeghan5
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views9 pages

Java Social Scheduler OOP Design

The document outlines the design and implementation of a console-based Social Scheduler in Java, featuring classes for User, Channel, Post, and SchedulerService. It demonstrates OOP concepts such as inheritance, method overloading, method overriding, polymorphism, and encapsulation. The main class, SchedulerAppMain, tests the functionality by adding users and channels, creating and scheduling posts, and listing their statuses.

Uploaded by

mehulmeghan5
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

QUESTION:

Design and implement a console-based Social Scheduler to create posts, schedule them
across channels, and track publish status using OOP in Java.

Requirements:
1. Create at least 4 classes:
o User – id, name, email, role.
o Channel – channelId, name (Twitter/LinkedIn/etc.), rateLimits, status.

o Post – postId, content, scheduledTime, channel, status.


o SchedulerService – validates, schedules, publishes, and reports posts.
2. Each class must include:
o ≥4 instance/static variables.
o A constructor to initialize values.
o ≥5 methods (getters/setters, createPost(), schedule(), publish(), listByChannel()).

3. Demonstrate OOPS Concepts:


o Inheritance → TwitterChannel/LinkedInChannel extend Channel with limits.
o Method Overloading → schedule() now/at time or with recurrence.
o Method Overriding → channel-specific validate()/publish() logic.

o Polymorphism → store channels as Channel and call overridden methods.


o Encapsulation → control post status and rate-limit counters.
4. Write a Main class (SchedulerAppMain) to test:
o Add users/channels, create posts, schedule/publish.
o List pending/published posts by channel/date.

o Show publish success rate and failures.


SOURCE CODE:
[Link] Tuesday 8 September, 2025, 5:31 pm
1 package v160;
2 import [Link].*;
3 class User {
4 private int id;
5 private String name;
6 private String email;
7 private String role;
8 public User(int id, String name, String email, String role) {
9 [Link] = id;
10 [Link] = name;
11 [Link] = email;
12 [Link] = role;
13 }
14 public String getName() { return name; }
15 public String getRole() { return role; }
16 }
17
18 class Channel {
19 protected int channelId;
20 protected String name;
21 protected int rateLimit;
22 protected String status;
23 public Channel(int channelId, String name, int rateLimit) {
24 [Link] = channelId;
25 [Link] = name;
26 [Link] = rateLimit;
27 [Link] = "Active";
28 }
29 public String getName() { return name; }
30 public boolean validate(Post post) {
31 return post != null && ![Link]().isEmpty();
32 }
33 public void publish(Post post) {
34 if (validate(post)) {
35 [Link]("Published");
36 [Link]("Published on " + name + ": " + post);
37 } else {
38 [Link]("Failed");
39 [Link]("Failed to publish on " + name);
40 }
41 }
42 }
43
44 class TwitterChannel extends Channel {
45 public TwitterChannel(int id) {
46 super(id, "Twitter", 5);
47 }
48 @Override
49 public boolean validate(Post post) {
50
51 return post != null && [Link]().length() <= 280;
52 }
53 }
54 class LinkedInChannel extends Channel {
55 public LinkedInChannel(int id) {
56 super(id, "LinkedIn", 10);
57 }
58 }
59
60 class Post {
61 private int postId;
62 private String content;
Page 1
[Link] Tuesday 9 September, 2025, 10:31 am
63 private String status;
64 private Channel channel;
65 public Post(int postId, String content, Channel channel) {
66 [Link] = postId;
67 [Link] = content;
68 [Link] = channel;
69 [Link] = "Draft";
70 }
71 public void setStatus(String status) { [Link] = status; }
72 public String getStatus() { return status; }
73 public Channel getChannel() { return channel; }
74 public String getContent() { return content; }
75 @Override
76 public String toString() {
77 return "Post#" + postId + " [" + [Link]() + "] " + status + " - " + content;
78 }
79 }
80
81 class SchedulerService {
82 private List<Post> posts = new ArrayList<>();
83
84 public void schedule(Post post) {
85 [Link]("Scheduled");
86 [Link](post);
87 }
88
89 public void schedule(Post post, String time) {
90 [Link]("Scheduled for " + time);
91 [Link](post);
92 }
93 public void publishAll() {
94 for (Post p : posts) {
95 [Link]().publish(p);
96 }
97 }
98 public void listByChannel(String channelName) {
99 for (Post p : posts) {
100 if ([Link]().getName().equals(channelName)) {
101 [Link](p);
102 }
103 }
104 }
105 }
106
107 public class vikaash {
108 public static void main(String[] args) {
109 User u1 = new User(1, "Pradeep", "p@[Link]", "Admin");
110 Channel twitter = new TwitterChannel(101);
111 Channel linkedin = new LinkedInChannel(102);
112 Post p1 = new Post(1, "Hello Twitter!", twitter);
113 Post p2 = new Post(2, "Hello LinkedIn!", linkedin);
114 SchedulerService scheduler = new SchedulerService();
115 [Link](p1);
116 [Link](p2);
117 [Link]("=== Scheduled Posts ===");
118 [Link]("Twitter");
119 [Link]("LinkedIn");
120 [Link]("\n=== Publishing ===");
121 [Link]();
122 }
123 }
124
OUTPUT:
Features Shown:
 Classes: User, Post, Channel, SchedulerService.

 Inheritance: TwitterChannel, LinkedInChannel extend Channel.


 Encapsulation: Private fields with setters/getters.
 Overloading: schedule() with/without time.
 Overriding: [Link]() overrides base method.
 Polymorphism: Channels stored as Channel but publish differently.

GIT-HUB REPOSITARY LINK: [Link]

You might also like