-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVideoStore.java
More file actions
46 lines (43 loc) · 1.1 KB
/
VideoStore.java
File metadata and controls
46 lines (43 loc) · 1.1 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
package MP1;
import java.util.*;
public class VideoStore {
ArrayList<Video> store = new ArrayList<>();
void addVideo(String name)
{
store.add(new Video(name));
}
void doCheckout(String name)
{
for(int i = 0; i < store.size(); i++)
{
if(store.get(i).getName().equals(name))
store.get(i).doCheckout();
}
}
void doReturn(String name)
{
for(int i = 0; i < store.size(); i++)
{
if(store.get(i).getName().equals(name))
store.get(i).doReturn();
}
}
void receiveRating(String name, int rating)
{
for(int i = 0; i < store.size(); i++)
{
if(store.get(i).getName().equals(name))
store.get(i).receiveRating(rating);
}
}
void listInventory()
{
System.out.println("---------------------------------------");
System.out.printf("%10s | %10s | %10s\n", "Video Name", "Checkout", "Ratings");
for(int i = 0; i < store.size(); i++)
{
System.out.printf("%10s | %10s | %10s\n", store.get(i).getName(), store.get(i).getCheckout(), store.get(i).getRating());
}
System.out.println("---------------------------------------");
}
}