Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Matthias Hoffmann
WIDAS-Semester-2
Commits
86b901dc
Commit
86b901dc
authored
Apr 10, 2020
by
matthias
Browse files
added Videothek
parent
5872be02
Changes
7
Hide whitespace changes
Inline
Side-by-side
Uebungen/OOP_3und4/src/videothek/CD.java
View file @
86b901dc
...
...
@@ -2,7 +2,15 @@ package videothek;
public
class
CD
extends
Medium
{
private
int
playTime
;
private
int
amountTracks
;
protected
int
playTimeMin
;
protected
int
amountTracks
;
public
CD
(){
}
public
CD
(
float
price
){
super
(
price
);
}
}
Uebungen/OOP_3und4/src/videothek/HoerspielCD.java
View file @
86b901dc
...
...
@@ -7,7 +7,7 @@ public class HoerspielCD extends CD {
@Override
public
void
lendMedia
()
{
super
.
lendMedia
();
public
float
lendMedia
()
{
return
super
.
lendMedia
()
+
1.5f
;
}
}
Uebungen/OOP_3und4/src/videothek/Medium.java
View file @
86b901dc
...
...
@@ -2,22 +2,22 @@ package videothek;
public
class
Medium
{
private
float
price
;
private
boolean
isLent
;
protected
float
price
;
public
boolean
isLent
;
public
Medium
()
{
}
public
Medium
(
float
price
)
{
this
.
price
=
price
;
isLent
=
false
;
}
public
void
lendMedia
()
{
public
float
lendMedia
()
{
isLent
=
true
;
return
price
;
}
}
Uebungen/OOP_3und4/src/videothek/MusikCD.java
View file @
86b901dc
...
...
@@ -4,4 +4,19 @@ public class MusikCD extends CD {
public
String
nameAlbum
;
public
String
artist
;
public
MusikCD
(
float
price
,
int
playTimeMin
)
{
super
(
price
);
super
.
playTimeMin
=
playTimeMin
;
}
@Override
public
float
lendMedia
()
{
if
(
playTimeMin
<=
20
)
{
return
super
.
lendMedia
()
-
0.5f
;
}
return
super
.
lendMedia
();
}
}
Uebungen/OOP_3und4/src/videothek/Programm.java
View file @
86b901dc
package
videothek
;
public
class
Programm
{
public
static
void
main
(
String
[]
args
){
public
static
void
main
(
String
[]
args
)
{
Videothek
videothek
=
new
Videothek
();
Medium
[]
allMedia
=
new
Medium
[
6
];
Medium
[]
lentMedia
=
new
Medium
[
6
];
Medium
media
=
new
Medium
(
3
);
Medium
media2
=
new
Medium
(
3
);
VHS
vhs
=
new
VHS
();
VHS
video
=
new
VHS
(
3
,
true
);
VHS
video1
=
new
VHS
(
3
,
false
);
vhs
.
lendMedia
();
MusikCD
musik
=
new
MusikCD
(
3
,
10
);
MusikCD
musik1
=
new
MusikCD
(
3
,
25
);
allMedia
[
0
]
=
media
;
allMedia
[
1
]
=
media2
;
allMedia
[
2
]
=
video
;
allMedia
[
3
]
=
video1
;
allMedia
[
4
]
=
musik
;
allMedia
[
5
]
=
musik1
;
//videothek.lendAllMedia(allMedia);
videothek
.
lendFirstThreeMedia
();
//System.out.println(lentMedia[2].price);
}
}
Uebungen/OOP_3und4/src/videothek/VHS.java
View file @
86b901dc
...
...
@@ -5,11 +5,20 @@ public class VHS extends Medium {
boolean
isClassic
;
public
VHS
(
float
price
,
boolean
isClassic
){
super
(
price
);
this
.
isClassic
=
isClassic
;
}
@Override
public
void
lendMedia
()
{
super
.
lendMedia
();
System
.
out
.
println
(
"VHS"
);
public
float
lendMedia
()
{
if
(
isClassic
)
{
return
super
.
lendMedia
()
+
1
;
}
return
super
.
lendMedia
();
}
}
Uebungen/OOP_3und4/src/videothek/Videothek.java
View file @
86b901dc
package
videothek
;
import
java.lang.reflect.Array
;
public
class
Videothek
{
int
[]
allMedia
;
int
[]
lentMedia
;
Medium
[]
lentMedia
;
public
float
lendAllMedia
(
Medium
...
medien
)
{
float
summary
=
0
;
for
(
Medium
m
:
medien
)
{
summary
+=
m
.
lendMedia
();
System
.
out
.
println
(
"Der Leihstatus des Mediums ist: "
+
m
.
isLent
);
}
System
.
out
.
println
(
"- -- -- -- -- -- -- -- -- -- -- -- -"
);
System
.
out
.
println
(
"Der Gesamtpreis beträgt: "
+
summary
+
" Euro."
);
return
summary
;
}
public
float
lendFirstThreeMedia
(){
float
summary
=
0
;
for
(
int
i
=
0
;
i
<=
2
;
i
++){
summary
+=
allMedia
[
i
].
price
;
}
System
.
out
.
println
(
"Der Gesamtpreis beträgt: "
+
summary
+
" Euro."
);
return
summary
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment