During my preparation for an exam in software engineering, I came across the following task in an old exam:
For a client, you create a new financial software whose task is, among other things, to perform tax calculations. The following requirements have been communicated to you by the Client:
- The system must be able to:
- calculate and display VAT for different countries and tax rates (Germany 19%, Austria 20%, Switzerland 8%).
- calculate and display the income tax according to country-specific tax tables (separate table for Germany, Austria, Switzerland).
- The system must allow the user to:
- enter the tax relevant data (gross amount for VAT, annual income for income tax)
- print the result of the tax calculation on a network printer.
- send the result of the tax calculation to the appropriate tax office.
Task 1: Capture the requirements communicated by the client in a domain model (class diagram) with the following information: classes, attributes, methods, relationships, multiplicities, relationship name.
Solution:
So I just want to know if the solutions the following tasks are correct:
-
As a developer, you use the Strategy Pattern to calculate the tax. To improve the design Apply the Strategy Pattern to the problem.
a) Which class of your design holds the context, which holds the strategy?
Solution:
- The class "TaxCalculation" holds the context
- The class "Tax" holds the abstract strategy defining the interface for the Context.
- VAT and IncomeTax: concrete Strategies
b) Model this part in a class diagram using the pattern.
Solution: In the class diagram above the strategy pattern is already modeled for the most part. In order to fulfill all requirements for a strategy pattern, the class "Tax" has to become an interface, which means that the subclasses "VAT" and "IncomeTax" have to implement all methods of "Tax", so "getTaxCode()" has to be implemented in both classes and "code" has to be constant.
c) What are the benefits for the tax calculation?
Solution: the advantages of using the strategy pattern for tax calculation are that it allows you to dynamically add new tax rules or modify existing ones. For example, a new class "VAT2", which is similar to "VAT", can also implement the interface "Tax".
my question is: Are my thoughts correct?
Thanks :)
Aucun commentaire:
Enregistrer un commentaire