44 lines
1.3 KiB
Python
44 lines
1.3 KiB
Python
|
import random
|
||
|
from data.Item import Item
|
||
|
from data.ItemType import ItemType
|
||
|
from data.Order import Order
|
||
|
|
||
|
|
||
|
class Generator:
|
||
|
def __init__(self, input_sequence_size: int, output_order_list_size: int):
|
||
|
self.input_sequence = self.generate_input_sequence(input_sequence_size)
|
||
|
self.output_order_list = self.generate_order_list(output_order_list_size)
|
||
|
|
||
|
def generate_order_list(self, output_order_list_size: int):
|
||
|
order_list = [Order]
|
||
|
for i in range(0, output_order_list_size):
|
||
|
order_list.append(self.generate_order())
|
||
|
|
||
|
return order_list
|
||
|
|
||
|
def generate_order(self) -> Order:
|
||
|
order_size = random.randint(1, 4)
|
||
|
|
||
|
items = [Item]
|
||
|
for i in range(order_size):
|
||
|
items.append(self.generate_item())
|
||
|
|
||
|
time_base = random.randint(8, 20)
|
||
|
final_time = time_base * order_size
|
||
|
|
||
|
value = sum(i.price for i in items)
|
||
|
|
||
|
return Order(final_time, items, value)
|
||
|
|
||
|
def generate_input_sequence(self, input_sequence_size):
|
||
|
sequence = [Item]
|
||
|
for i in range(0, input_sequence_size):
|
||
|
sequence.append(self.generate_item())
|
||
|
|
||
|
return sequence
|
||
|
|
||
|
@staticmethod
|
||
|
def generate_item() -> Item:
|
||
|
randomly_picked_type = random.choice(list(ItemType))
|
||
|
return Item(randomly_picked_type)
|