I have an OOD/OOP problem, where I need to design a scheduler to output the date for certain activities with different frequencies. For example, I can have this event to schedule every one hour, every 4 hours, every day, or every week, even every month. I can also set the event to happen at noon, ..
I am trying to create a variation of a bubble sort and I am completely lost. When run, the code should return: >>> board = MarblesBoard((1,3,0,2)) >>> solver = Solver(board) >>> solver.solve() 1 3 0 2 3 0 2 1 0 2 1 3 2 1 3 0 1 2 3 0 2 3 0 ..
I am new to python. I’m writing a testing application for another analytical tool. That tool outputs various kinds of files we call ‘artifacts’. Each type of artifact is a data file of some kind. I created a parent class called Artifact that has load() and compare() functions. So, say I have two types of ..
I am trying to write a program that has: a function that creates a deck of cards, 52 by default or just 13 when a suit is provided. AND a function that removes the first card_count cards from the deck, returns them as a list and returns an appropriate error when out of cards. Expected ..
Let’s say I have these two classes: class Order: def __init__(self, dish, status): self.dish = dish self.status = status def cook(self): self.status = ‘cooking’ def serve(self): self.status = ‘served’ and class Orders: def __init__(self, all_orders): self.lst = all_orders self.waiting = [o for o in self.lst if o.status==’waiting’] self.cooking = [o for o in self.lst if ..
Let’s say I have these two classes: class Ball: def __init__(self, shape): self.shape = shape and class Balls: def __init__(self, *args): self.rounds = [b for b in args if b.shape==’round’] self.ovals = [b for b in args if b.shape==’oval’] The problem is, after I’ve called something like balls = Balls(Ball(’round’), Ball(’round’), Ball(‘oval’)), each ball in ..
I have a problem, I enum with several types of certain object class Type(Enum): TYPE_A TYPE_B TYPE_C TYPE_D …. class Something(): def __init__(self): self.TYPE_A_list =  self.TYPE_B_list =  self.TYPE_C_list =  self.TYPE_D_list =  … def add_data(self, type: Type, value: int): if type == TYPE_A: self.TYPE_A_list.append(value) elif type == TYPE_B: self.TYPE_A_list.append(value) elif type == ..
I am learning OOP with Python and I consider that I have already understood the basics to understand how to create and instantiate a class but I have a question of syntax. Reviewing different examples to practice I have been able to see that a class can be created with slight differences but that I ..
I have a text file with a list of car types, for example: Ferrari Volvo Audi Tesla In my code I have the following structure class Car(ABC): … @abstractmethod def refuel(self): pass class Ferrari(Car): … def refuel(self): print(‘Refueling a Ferrari’) class Tesla(Car): … def refuel(self): print(‘Refueling a Tesla’) … I want to parse the text ..
I have a python application and a postgresql database, which has two tables that are related to each other: "Equipment" stores records with information about types of equipment eg description, picture, and an id field "Item" stores records about individual items of equipment, e.g serial number, and an id field. I have created a class ..