Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started