Repository navigation
Expand file tree
/
Copy pathProject1.java
More file actions
123 lines (91 loc) · 2.89 KB
/
Copy pathProject1.java
File metadata and controls
123 lines (91 loc) · 2.89 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
package project.pkg1;
import java.util.Scanner;
import java.util.*;
public class Project1 {
public static void main(String[] args) {
user u1 = new user();
user u2 = new user();
Scanner s = new Scanner (System.in );
System.out.println("Blog");
System.out.println("Do you want to create blog 1 = Yes 2 = No");
int a = s.nextInt();
if ( a==1 )
{
System.out.println(" Enter username ");
String usr=s.next();
System.out.println(" Enter password ");
String pwd = s.next();
u1.validate(usr, pwd);
}
else {
System.out.println(" thanks ");
}
}
}
class Blog
{
Scanner s = new Scanner (System.in );
// this is for the path of database
String image;
String video;
String text;
String title;
String visibility;
public void visibility(){
System.out.println("\n Visitor View ");
if( visibility == "visible"){
System.out.println("BLOG POSTS");
System.out.println(title);
System.out.println(text);
}
else{
System.out.println("Access Denied");
}
}
}
class user extends Blog
{
String Username = "abc";
String Password = "abc123";
public void validate (String usr, String pwd )
{
if (pwd.equals(Password) && usr.equals(Username))
{
System.out.println("Valid Username/Password!");
System.out.println("\n\n User view");
Blog b1 = new Blog();
System.out.println("\n\n");
System.out.println("Enter blog title: ");
String title = s.next();
System.out.println("Enter blog text: ");
String text = s.next();
System.out.println("Enter the visibility of your post(visible/invisible):");
String visibility = s.next();
System.out.println("\n\n");
System.out.println("Do you want to use visitor view blog 1 = Yes 2 = No");
int a = s.nextInt();
if ( a==1 )
{
visibility();
}
else{
System.out.println("\n\n User view");
System.out.println("BLOG POSTS");
System.out.println(title);
System.out.println(text);
}
}
else
{
System.out.println("Invalid Username/Password!");
}
}
}
class visitor extends Blog
{
@Override
public void visibility() {
super.visibility(); //To change body of generated methods, choose Tools | Templates.
visibility();
}
}