1

I am new to object-oriented programming I need to write a BankDataWriterBase base class in the following program using the class diagram given in below to the code. I cannot understand the complete thing that the class diagram has, anybody here to know & explain to me what they actually saying using the class diagram

import pandas as pd

class ExcelParser:
    def __init__(self):
        self.config = []       
    
    def extract(self, file_name):
        ra

here is the class diagram for the BankDataWriterBase class, i have completed the EXcelParser class but i dont know how to approach the BankDataWriterBase class 

[![enter image description her


1 Answers1

0

Since you already have an ExcelParser we'll start from there, But first perhaps take a look at this

ExcelParser will have an attribute config which is a List[str] and the function extract which you already have. You will need to store an instance of a BankDataWriterImpl.

BankDataWriterBase will be the base of BankDataWriterImpl(<-- needs to inherit from the base class) and will have some attributes: input_path, output_path and bank_identifier And a function write_file.

BankDataWriterImpl will have an extract_json function with a string argument and no return. BankDataWriterImpl will also store between 1 and n Tasks(so a list of tasks).

Each Task will have a run function that has no arguments and returns nothing.

Finally if you want to denote types in python take a look at the typing module

Robin Dillen
  • 704
  • 5
  • 11
  • please see and correct my updated approach –  Jan 11 '22 at 19:09
  • First define Task or BankDataWriterBase then after those 2 BankDataWriterImpl then at last ExcelParser. To inherit from a class in python just do `class BankDataWriterImpl(BankDataWriterBase)`. But your original question is solved and the follow up question isn't really on topic anymore so ask a new question if you still have any. – Robin Dillen Jan 11 '22 at 19:27
  • done robin could you explain bit more about that BankDataWriterBase class diagram –  Jan 11 '22 at 19:31
  • What you had in your code was correct, i really can't explain more then in the answer unless you have a specific question. – Robin Dillen Jan 11 '22 at 19:39
  • I have raised a specific question for the could you explain it to me 'https://stackoverflow.com/questions/70672511/writing-base-class-using-python-object-oriented-programming' –  Jan 11 '22 at 19:42