FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Media-Library/MediaSystem.java at master · mayank97/Media-Library · GitHub
mayank97
/
Media-Library
Public
Notifications
You must be signed in to change notification settings
Fork
1
Star
0
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Media-Library
/
MediaSystem.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
233 lines (207 loc) · 5.35 KB
Breadcrumbs
Media-Library
/
MediaSystem.java
Copy path
File metadata and controls
233 lines (207 loc) · 5.35 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
/*
Dewansh Gautam 2015025
Mayank Kumar 2015055
*/
package
lab5
;
import
java
.
io
.
File
;
import
java
.
io
.
IOException
;
import
java
.
util
.*;
public
class
MediaSystem
{
public
static
void
RateEdit
()
{
Scanner
in
=
new
Scanner
(
System
.
in
);
System
.
out
.
println
(
" 1. Edit rating of a song."
);
System
.
out
.
println
(
" 2. Edit the rating of a movie."
);
int
request
=
in
.
nextInt
();
new
Database
();
int
oldRate
=
0
;
int
newRate
=
0
;
if
(
request
==
1
)
{
System
.
out
.
println
(
" Enter the name of the song"
);
String
var
=
in
.
next
();
int
namecheck
=
0
;
for
(
int
j
=
0
;
j
<
Database
.
countSong
;
j
++)
{
if
(
var
.
equals
(
Database
.
song
[
j
].
getTitle
()))
{
int
check
=
1
;
namecheck
=
1
;
while
(
check
==
1
)
{
oldRate
=
Integer
.
parseInt
(
Database
.
song
[
j
].
getRating
());
System
.
out
.
println
(
"Enter the new rating"
);
int
rate
=
in
.
nextInt
();
if
(
rate
<
0
)
{
try
{
throw
new
MyException
(
"(EXCEPTION)rating less tha 0 in update"
)
;
}
catch
(
MyException
e
){
System
.
out
.
println
(
e
.
getMessage
());
}
break
;}
newRate
=
rate
;
String
rating
=
Integer
.
toString
(
rate
);
Database
.
song
[
j
].
setRating
(
rating
);
System
.
out
.
printf
(
"Rating of the song updated from %d to %d"
,
oldRate
,
newRate
);
Database
.
write
(
1
);
break
;
}
}
}
//System.out.printf("Rating of the song updated from %d to %d",oldRate, newRate);
if
(
namecheck
==
0
){
try
{
throw
new
MyException
(
"(EXCEPTION) name not found"
)
;
}
catch
(
MyException
e
){
System
.
out
.
println
(
e
.
getMessage
());
}
}
System
.
out
.
println
();
}
else
if
(
request
==
2
)
{
System
.
out
.
println
(
" Enter the name of the movie"
);
String
var
=
in
.
next
();
int
namecheck
=
0
;
for
(
int
j
=
0
;
j
<
Database
.
countMovie
;
j
++)
{
if
(
var
.
equals
(
Database
.
movie
[
j
].
getTitle
()))
{
namecheck
=
1
;
oldRate
=
Integer
.
parseInt
(
Database
.
movie
[
j
].
getRating
());
System
.
out
.
println
(
"Enter the new rating"
);
int
rate
=
in
.
nextInt
();
if
(
rate
<
0
)
{
try
{
throw
new
MyException
(
"(EXCEPTION)rating less tha 0 in update"
)
;
}
catch
(
MyException
e
){
System
.
out
.
println
(
e
.
getMessage
());
}
break
;}
newRate
=
rate
;
String
rating
=
Integer
.
toString
(
rate
);
Database
.
movie
[
j
].
setRating
(
rating
);
Database
.
write
(
2
);
System
.
out
.
printf
(
"Rating of the movie updated from %d to %d"
,
oldRate
,
newRate
);
break
;
}
}
if
(
namecheck
==
0
){
try
{
throw
new
MyException
(
"(EXCEPTION) movie name not found"
)
;
}
catch
(
MyException
e
){
System
.
out
.
println
(
e
.
getMessage
());
}
}
System
.
out
.
println
();
}
else
{
try
{
throw
new
MyException
(
"Enter a valid data"
);
}
catch
(
MyException
e
)
{
System
.
out
.
println
(
e
.
getMessage
());
}
}
}
public
static
void
main
(
String
[]
args
)
{
int
sum
=
0
;
int
counter
=
0
;
while
(
sum
!=-
1
)
{
System
.
out
.
println
(
"Enter a valid choice(any character between a to h or 5(for encryption/decryption) : "
);
System
.
out
.
println
(
" OR"
);
System
.
out
.
println
(
"Press 0 to terminate the program."
);
if
(
counter
==
0
&&
sum
>=
1
){
try
{
throw
new
MyException
(
"Enter a valid choice(EXCEPTION)"
);
}
catch
(
MyException
e
)
{
System
.
out
.
println
(
e
.
getMessage
());
}
}
Scanner
in
=
new
Scanner
(
System
.
in
);
String
order
=
in
.
next
();
if
((
order
).
equals
(
"0"
))
{
System
.
out
.
println
(
"Program Terminated."
);
break
;
}
if
((
order
).
equals
(
"f"
))
{
counter
++;
RateEdit
();
}
else
if
(
order
.
equals
(
"g"
))
{
counter
++;
System
.
out
.
printf
(
"Number of songs in the library : "
);
System
.
out
.
println
(
Database
.
countSong
);
System
.
out
.
printf
(
"Number of movies in the library : "
);
System
.
out
.
println
(
Database
.
countMovie
);
System
.
out
.
println
();
}
else
if
(
order
.
equals
(
"c"
))
{
counter
++;
System
.
out
.
println
(
"Enter the value of k"
);
int
k
=
in
.
nextInt
();
DataStructure
.
TreeSetSong
(
k
);
DataStructure
.
TreeSetMovie
(
k
);
}
else
if
(
order
.
equals
(
"b"
))
{
counter
++;
DataStructure
.
HashMap
();
}
else
if
(
order
.
equals
(
"h"
))
{
counter
++;
System
.
out
.
println
(
"Enter the name of the movie : "
);
String
movie
=
in
.
next
();
DataStructure
.
HashTable
(
movie
);
}
else
if
(
order
.
equals
(
"e"
))
{
counter
++;
System
.
out
.
println
(
"Enter the name of the Director : "
);
String
director
=
in
.
next
();
DataStructure
.
HashDirector
(
director
);
}
else
if
(
order
.
equals
(
"d"
))
{
counter
++;
System
.
out
.
println
(
"Enter the genre of song to be searched : "
);
String
genre
=
in
.
next
();
DataStructure
.
FindGenre
(
genre
);
}
else
if
(
order
.
equals
(
"a"
))
{
counter
++;
int
i
=
1
;
Media
.
Serial
(
i
);
}
else
if
(
order
.
equals
(
"5"
))
{
counter
++;
File
f1
=
null
;
try
{
StreamClass
f2
=
new
StreamClass
(
f1
);
f2
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
System
.
out
.
println
();
System
.
out
.
println
(
"The Song and Media files has been encrypted to EncrytedSong and EncryptedMovie files respectively."
);
System
.
out
.
println
(
"The encrypted files has been decrypted and stored in DecryptedSong and DecryptedMovie respectively."
);
System
.
out
.
println
();
}
sum
++;
}
}
}
Back
|
FazBrowse Home
|
New Git URL