-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFactoryDemo.java
More file actions
40 lines (31 loc) · 1.63 KB
/
FactoryDemo.java
File metadata and controls
40 lines (31 loc) · 1.63 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
/*
MADE BY: ANKIT AGRAWAL
ROLL NO.: IMT2019010
PURPOSE OF FILE: This file contains the derived class of the
parent class Factory. The name of the derived
class is "FactoryDemo". This class can be
used to create instances of derived classes
of Network, Highway, Hub and Truck.
*/
package demo19010;
import base.*;
import java.util.*;
public class FactoryDemo extends Factory
{
public Network createNetwork() //This function creates a Network, which can be used to hold trucks, highways and hubs
{
return new DerivedNetwork(); //We return a newly created instance of DerivedNetwork, which extends abstract class Network
}
public Highway createHighway() //This function creates a Highway, on which trucks can move, and can connect two hubs unidirectionally
{
return new DerivedHighway(); //We return a newly created instance of DerivedHighway, which extends abstract class Highway
}
public Hub createHub(Location location) //This function creates a Hub (having Location as parameter "location"), which direct trucks to destination locations
{
return new DerivedHub(location); //We return a newly created instance of DerivedHub, which extends abstract class Hub.
}
public Truck createTruck() //This function creates a Truck, which move from hub to hub, trying to get to its final destination
{
return new DerivedTruck(); //We return a newly created instance of DerivedTruck, which extends abstract class Truck
}
}