-
Notifications
You must be signed in to change notification settings - Fork 0
/
personFactory.java
40 lines (35 loc) · 1.01 KB
/
personFactory.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
/**
* Factory Pattern implemented
*
* @author Nirmit Agrawal, [email protected]
* @version 1.3
* @since 10-17-2022
*/
public class personFactory extends Person {
personFactory(ProductMenu pm)
{
super(pm);
}
@Override
public ProductMenu createProductMenu()
{
return null;
}
public void startOperation(String username, String category)
{
}
public static Person createObject(int userType, String category){
System.out.println("Factory Pattern Initiated");
if(userType == 0 && category.equals("Meat"))
{
return (new Buyer(new MeatProductMenu()));
} else if (userType == 0 && category.equals("Produce")) {
return (new Buyer(new ProduceProductMenu()));
} else if (userType == 1 && category.equals("Meat")) {
return (new Seller(new MeatProductMenu()));
}else
{
return (new Seller(new ProduceProductMenu()));
}
}
}