Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhancement] change to enum or Action Class as aggregation #4

Closed
Tracked by #2
1chooo opened this issue Jun 9, 2024 · 0 comments · Fixed by #10
Closed
Tracked by #2

[Enhancement] change to enum or Action Class as aggregation #4

1chooo opened this issue Jun 9, 2024 · 0 comments · Fixed by #10
Assignees
Labels
enhancement New feature or request

Comments

@1chooo
Copy link
Owner

1chooo commented Jun 9, 2024

In the program, we need to avoid using variables as strings because we might change the names of these variables in the future. Renaming them everywhere would be time-consuming. Instead, we should use enums or an Action class for aggregation.

public void mousePressed(MouseEvent e) {
System.out.println("x: " + e.getX() + " y: " + e.getY());
Shape obj = null;
switch (shapeType) {
case "Class":
obj = new ClassObj(e.getX(), e.getY(), "Class");
break;
case "Use Case":
obj = new UseCaseObj(e.getX(), e.getY(), "Use Case");
break;
default:
System.out.println("Unsupported shape type");
break;
}
if (obj != null) {
canvas.addShape(obj);
}
}

public Line createLine(String type, Point start, Point end) {
Line line = null;
switch (type) {
case "AssociationLine":
line = new AssociationLine(start.x, start.y, end.x, end.y);
break;
case "GeneralizationLine":
line = new GeneralizationLine(start.x, start.y, end.x, end.y);
break;
case "CompositionLine":
line = new CompositionLine(start.x, start.y, end.x, end.y);
break;
}
return line;
}

@1chooo 1chooo added the enhancement New feature or request label Jun 9, 2024
@1chooo 1chooo self-assigned this Jun 9, 2024
1chooo added a commit that referenced this issue Jun 13, 2024
1chooo added a commit that referenced this issue Jun 13, 2024
1chooo added a commit that referenced this issue Jun 13, 2024
1chooo added a commit that referenced this issue Jun 13, 2024
1chooo added a commit that referenced this issue Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant