Question: code scaffold: from _ _ future _ _ import annotations from dataclasses import dataclass from computer import Computer from typing import TYPE _ CHECKING, Union

code scaffold:
from __future__ import annotations
from dataclasses import dataclass
from computer import Computer
from typing import TYPE_CHECKING, Union
# Avoid circular imports for typing.
if TYPE_CHECKING:
from virus import VirusType
@dataclass
class RouteSplit:
"""
A split in the route.
_____top______
/\
->-following-
\____bottom____/
"""
top: Route
bottom: Route
following: Route
def remove_branch(self)-> RouteStore:
"""Removes the branch, should just leave the remaining following route."""
raise NotImplementedError()
@dataclass
class RouteSeries:
"""
A computer, followed by the rest of the route
--computer--following--
"""
computer: Computer
following: Route
def remove_computer(self)-> RouteStore:
"""
Returns a route store which would be the result of:
Removing the computer at the beginning of this series.
"""
raise NotImplementedError()
def add_computer_before(self, computer: Computer)-> RouteStore:
"""
Returns a route store which would be the result of:
Adding a computer in series before the current one.
"""
raise NotImplementedError()
def add_computer_after(self, computer: Computer)-> RouteStore:
"""
Returns a route store which would be the result of:
Adding a computer after the current computer, but before the following route.
"""
raise NotImplementedError()
def add_empty_branch_before(self)-> RouteStore:
"""Returns a route store which would be the result of:
Adding an empty branch, where the current routestore is now the following path.
"""
raise NotImplementedError()
def add_empty_branch_after(self)-> RouteStore:
"""
Returns a route store which would be the result of:
Adding an empty branch after the current computer, but before the following route.
"""
raise NotImplementedError()
RouteStore = Union[RouteSplit, RouteSeries, None]
@dataclass
class Route:
store: RouteStore = None
def add_computer_before(self, computer: Computer)-> Route:
"""
Returns a *new* route which would be the result of:
Adding a computer before everything currently in the route.
"""
raise NotImplementedError()
def add_empty_branch_before(self)-> Route:
"""
Returns a *new* route which would be the result of:
Adding an empty branch before everything currently in the route.
"""
raise NotImplementedError()
def follow_path(self, virus_type: VirusType)-> None:
"""Follow a path and add computers according to a virus_type."""
raise NotImplementedError()
def add_all_computers(self)-> list[Computer]:
"""Returns a list of all computers on the route."""
raise NotImplementedError()
 code scaffold: from __future__ import annotations from dataclasses import dataclass from

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!