-
Notifications
You must be signed in to change notification settings - Fork 0
/
Sold_Publication.java
106 lines (91 loc) · 3.23 KB
/
Sold_Publication.java
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
package com.company;
import java.util.Date;
import static com.company.Book_Operation.Sold_Book;
import static com.company.Book_Operation.books;
import static com.company.Booklet_Operation.Sold_Booklet;
import static com.company.Booklet_Operation.booklets;
import static com.company.Magazine_operation.Sold_Magazine;
import static com.company.Magazine_operation.magazines;
import static com.company.Student_operation.students;
public class Sold_Publication {
Date Operation_Date;
Publication Sold;
Student buyer;
private Sold_Publication(Publication a, Student buyer) {
Operation_Date = new Date();
this.buyer = buyer;
Sold = a;
if (a instanceof Booklet) {
Booklet_Operation.Sold_Booklet.add(this);
Booklet_Operation.Check_Booklets_In_Stock();
} else if (a instanceof Book) {
Book_Operation.Sold_Book.add(this);
Book_Operation.Check_Books_In_Stock();
} else if (a instanceof Magazine) {
Magazine_operation.Sold_Magazine.add(this);
Magazine_operation.Check_Magazines_In_Stock();
}
}
public static boolean Buy_Publication(String P, String ID) {
Publication pub = null;
boolean enter = true;
String p = new String();
if (enter) {
for (Book a : books) {
if (a.Title.equalsIgnoreCase(P)) ;
{
pub = a;
enter = false;
p = "book";
}
}
}
if (enter) {
for (Booklet a : booklets) {
if (a.Title.equalsIgnoreCase(P)) ;
{
pub = a;
enter = false;
p = "booklet";
}
}
}
if (enter) {
for (Magazine a : magazines) {
if (a.Title.equalsIgnoreCase(P)) ;
{
pub = a;
enter = false;
p = "magazine";
}
}
//return false;
}
Student S = null;
for (Student s : students) {
if (s.ID.equals(ID)) {
S = s;
if (p.equalsIgnoreCase("book")) {
Sold_Publication g = new Sold_Publication(pub, S);
Sold_Book.add(g);
pub.Num_Of_CopyINStock--;
pub.Num_of_SoldCopy++;
return true;
} else if (p.equalsIgnoreCase("booklet")) {
Sold_Publication g = new Sold_Publication(pub, S);
Sold_Booklet.add(g);
pub.Num_Of_CopyINStock--;
pub.Num_of_SoldCopy++;
return true;
} else if (p.equalsIgnoreCase("magazine")) {
Sold_Publication g = new Sold_Publication(pub, S);
Sold_Magazine.add(g);
pub.Num_Of_CopyINStock--;
pub.Num_of_SoldCopy++;
return true;
}
}
}
return false;
}
}