Implement a class Browser
with a method render()
. Extend this class into ChromeBrowser
and FirefoxBrowser
, each implementing the render()
method appropriately.
Example 1:
Input: ChromeBrowser Output: "Rendering webpage in Chrome"
Example 2:
Input: FirefoxBrowser Output: "Rendering webpage in Firefox"
Override the render()
method in each subclass to return the respective rendering method.
class Browser: def render(self): pass class ChromeBrowser(Browser): def render(self): return "Rendering webpage in Chrome" class FirefoxBrowser(Browser): def render(self): return "Rendering webpage in Firefox" # Test the classes chrome = ChromeBrowser() print(chrome.render()) # Output: Rendering webpage in Chrome firefox = FirefoxBrowser() print(firefox.render()) # Output: Rendering webpage in Firefox
Unlock AI & Data Science treasures. Log in!