Question

In: Computer Science

Create a generic superclass Shoe, which has at least 3 subclasses with attributes as shown below:...

Create a generic superclass Shoe, which has at least 3 subclasses with attributes as shown below: class Shoe: Attributes: self.color, self.brand class Converse (Shoe): # Inherits from Shoe Attributes: self.lowOrHighTop, self.tongueColor, self.brand = "Converse" class CombatBoot (Shoe): # Inherits from Shoe Attributes: self.militaryBranch, self.DesertOrJungle class Sandal (Shoe): # Inherits from Shoe Attributes: self.openOrClosedToe, self.waterproof Implement the classes in Python. Create a separate test module where 2 instances of each subclass are created. Test the methods by displaying their information.

Solutions

Expert Solution

(*Note: Please up-vote. If any doubt, please let me know in the comments)

CODE (Classes):

class Shoe:

    def __init__(self,color,brand):

        self.color = color

        self.brand = brand

    

    def __str__(self):

        return f"Color: {self.color}, Brand: {self.brand}"

class Converse (Shoe): # Inherits from Shoe Attributes:

    def __init__(self,color,lowOrHighTop,tongueColor):

        Shoe.__init__(self,color,"Converse")

        self.lowOrHighTop = lowOrHighTop

        self.tongueColor =  tongueColor

    def __str__(self):

        return f"{Shoe.__str__(self)}, Top: {self.lowOrHighTop}, Tongue color: {self.tongueColor}"

class CombatBoot (Shoe): # Inherits from Shoe Attributes:

    def __init__(self,color,brand, militaryBranch,DesertOrJungle):

        Shoe.__init__(self,color,brand)

        self.militaryBranch = militaryBranch

        self.DesertOrJungle = DesertOrJungle

    def __str__(self):

        return f"{Shoe.__str__(self)}, militaryBranch: {self.militaryBranch}, DesertOrJungle: {self.DesertOrJungle}"


class Sandal (Shoe): # Inherits from Shoe

    def __init__(self,color,brand,openOrClosedToe,waterproof):

        Shoe.__init__(self,color,brand)

        self.openOrClosedToe = openOrClosedToe

        self.waterproof =  waterproof

    def __str__(self):

        return f"{Shoe.__str__(self)}, openOrClosedToe: {self.openOrClosedToe}, waterproof: {self.waterproof}"

CODE SCREENSHOT (For indentation ref.)

Testing CODE:

cnv1 = Converse("red","low top","blue")

cnv2 = Converse("black","high top","teal")

print(cnv1)

print(cnv2)

cnv1 = CombatBoot("brown","Niki","marine","desert")

cnv2 = CombatBoot("black","Ranger","navy","jungle")

print(cnv1)

print(cnv2)

cnv1 = Sandal("yellow","Bata","Open top","yes")

cnv2 = Sandal("green","Niki","closed top","no")

print(cnv1)

print(cnv2)

TEST OUTPUT SCREENSHOT:


Related Solutions

In Java, implement a superclass Appointment and subclasses Onetime, Daily, and Monthly. An appointment has a...
In Java, implement a superclass Appointment and subclasses Onetime, Daily, and Monthly. An appointment has a description (for example, “see the dentist”) and a date. Write a method occursOn(int year, int month, int day) that checks whether the appointment occurs on that date. For example, for a monthly appointment, you must check whether the day of the month matches. In Main Class, fill an array of Appointment objects with a mixture of appointments i.e Onetime, Daily, and Monthly (at least...
How to write a Java program that has a base class with methods and attributes, subclasses...
How to write a Java program that has a base class with methods and attributes, subclasses with methods and attributes. Please use any example you'd like.
1. Write a superclass encapsulating a rectangle. A rectangle has two attributes representing the width and...
1. Write a superclass encapsulating a rectangle. A rectangle has two attributes representing the width and the height of the rectangle. It has methods returning the perimeter and the area of the rectangle. This class has a subclass, encapsulating a parallelepiped, or box. A parallelepiped has a rectangle as its base, and another attribute, its length; it has two methods that calculate and return its area and volume. You also need to include a client class (with the main method)...
Use the shoe print lengths and heights shown below to find the regression​ equation, letting shoe...
Use the shoe print lengths and heights shown below to find the regression​ equation, letting shoe print lengths be the predictor​ (x) variable. Then find the best predicted height of a male who has a shoe print length of 27.627.6 cm. Would the result be helpful to police crime scene investigators in trying to describe the​ male? Use a significance level of alphaαequals=0.05 Shoe Print​ (cm) 29.729.7 29.729.7 31.631.6 31.931.9 27.127.1 Foot Length​ (cm) 25.7 25.4 27.9 26.7 25.1 Height​...
USING SQL Create a table named Zones with the attributes and assumptions indicated below. Attributes: the...
USING SQL Create a table named Zones with the attributes and assumptions indicated below. Attributes: the zone ID, the lowest and the highest accepted temperature. Assumptions: the ID will be the primary key and have one or two digits, the temperatures (in Fahrenheit) will be at most two digits and a possible minus sign, none of the temperatures can be NULL. Populate table Zones so that it has the following rows: id lowerTemp higherTemp 2 -50 -40 3 -40 -30...
Create 3 Classes per the following instructions: 1) Create an abstract parent superclass called MobileDevices and...
Create 3 Classes per the following instructions: 1) Create an abstract parent superclass called MobileDevices and include only the attributes that are common to both cellphones and tablets like iPads. Also create at least one abstract method. 2) Create a child class that extends the MobileDevices class called DeviceType that has attributes and methods regarding the type of device. 3) Create a third class that extends the DeviceType class called DeviceBrand that has attributes and methods for both Apple and...
Create a generic function max() in C++, to find maximum of 3 generic type arguments, then...
Create a generic function max() in C++, to find maximum of 3 generic type arguments, then test this function with char, int and float type.
-------------- WRITE IN C# ------------------- Create two subclasses called outpatient and inpatient which inherit from the...
-------------- WRITE IN C# ------------------- Create two subclasses called outpatient and inpatient which inherit from the patient base class. The outpatient class has an additional data field called doctorOfficeID and the inpatient class has an additional data item called hospitalID. Write a main method that creates inpatient and outpatient objects. Sets data for these objects and display the data.
Challenge: Documents Description: Create a class in Python 3 named Document that has specified attributes and...
Challenge: Documents Description: Create a class in Python 3 named Document that has specified attributes and methods for holding the information for a document and write a program to test the class. Purpose: The purpose of this challenge is to provide experience creating a class and working with OO concepts in Python 3. Requirements: Write a class in Python 3 named Document that has the following attributes and methods and is saved in the file Document.py. Attributes __title is a...
Description: Create a class in Python 3 named Animal that has specified attributes and methods. Purpose:...
Description: Create a class in Python 3 named Animal that has specified attributes and methods. Purpose: The purpose of this challenge is to provide experience creating a class and working with OO concepts in Python 3. Requirements: Write a class in Python 3 named Animal that has the following attributes and methods and is saved in the file Animal.py. Attributes __animal_type is a hidden attribute used to indicate the animal’s type. For example: gecko, walrus, tiger, etc. __name is a...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT