Question: this is the code scaffold for virus.py: from _ _ future _ _ import annotations from abc import ABC, abstractmethod from computer import Computer from
this is the code scaffold for virus.py:
from future import annotations
from abc import ABC, abstractmethod
from computer import Computer
from route import Route, RouteSeries
from branchdecision import BranchDecision
class VirusTypeABC:
def initself None:
self.computers
def addcomputerself computer: Computer None:
self.computers.appendcomputer
@abstractmethod
def selectbranchself topbranch: Route, bottombranch: Route BranchDecision:
raise NotImplementedError
class TopVirusVirusType:
def selectbranchself topbranch: Route, bottombranch: Route BranchDecision:
# Always select the top branch
return BranchDecision.TOP
class BottomVirusVirusType:
def selectbranchself topbranch: Route, bottombranch: Route BranchDecision:
# Always select the bottom branch
return BranchDecision.BOTTOM
class LazyVirusVirusType:
def selectbranchself topbranch: Route, bottombranch: Route BranchDecision:
Try looking into the first computer on each branch,
take the path of the least difficulty.
toproute typetopbranch.store RouteSeries
botroute typebottombranch.store RouteSeries
if toproute and botroute:
topcomp topbranch.store.computer
botcomp bottombranch.store.computer
if topcomp.hackingdifficulty botcomp.hackingdifficulty:
return BranchDecision.TOP
elif topcomp.hackingdifficulty botcomp.hackingdifficulty:
return BranchDecision.BOTTOM
else:
return BranchDecision.STOP
# If one of them has a computer, don't take it
# If neither do then take the top branch.
if toproute:
return BranchDecision.BOTTOM
return BranchDecision.TOP
class RiskAverseVirusVirusType:
def selectbranchself topbranch: Route, bottombranch: Route BranchDecision:
This virus is risk averse and likes to choose the path with the lowest risk factor.
raise NotImplementedError
class FancyVirusVirusType:
CALCSTR
def selectbranchself topbranch: Route, bottombranch: Route BranchDecision:
This virus has a fancypants and likes to overcomplicate its approach.
raise NotImplementedError
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
