Spaces:
Sleeping
Sleeping
File size: 1,910 Bytes
5e84ffc 448b42a 5e84ffc 448b42a 5e84ffc 448b42a 5e84ffc 448b42a 5e84ffc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
"""Factory class for creating melody practice applications."""
from improvisation_lab.application.interval_practice import (
ConsoleIntervalPracticeApp, WebIntervalPracticeApp)
from improvisation_lab.application.piece_practice import (
ConsolePiecePracticeApp, WebPiecePracticeApp)
from improvisation_lab.config import Config
from improvisation_lab.service import (IntervalPracticeService,
PiecePracticeService)
class PracticeAppFactory:
"""Factory class for creating melody practice applications."""
@staticmethod
def create_app(app_type: str, practice_type: str, config: Config):
"""Create a melody practice application.
Args:
app_type: Type of application to create.
practice_type: Type of practice to create.
config: Config instance.
"""
if app_type == "web":
if practice_type == "piece":
piece_service = PiecePracticeService(config)
return WebPiecePracticeApp(piece_service, config)
elif practice_type == "interval":
interval_service = IntervalPracticeService(config)
return WebIntervalPracticeApp(interval_service, config)
else:
raise ValueError(f"Unknown practice type: {practice_type}")
elif app_type == "console":
if practice_type == "piece":
piece_service = PiecePracticeService(config)
return ConsolePiecePracticeApp(piece_service, config)
elif practice_type == "interval":
interval_service = IntervalPracticeService(config)
return ConsoleIntervalPracticeApp(interval_service, config)
else:
raise ValueError(f"Unknown practice type: {practice_type}")
else:
raise ValueError(f"Unknown app type: {app_type}")
|