Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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()
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions