ss Point:     """     A point in a two-dimensional coordinate plane     """          def __init__(self, x, y):         """         Create a point with an x and y coordinate         """         self.x = x         self.y = y              def __str__(self):         """         Generate a string representation of a point         """         return "(" + str(self.x) + "," + str(self.y) + ")" ############################ # Part 1 - Rectangle Class ############################ class Rectangle:     """     A rectangle in a two-dimensional coordinate plane     """          def __init__(self, bottom_left_x, bottom_left_y, top_right_x, top_right_y):         """         Create a rectangle defined by

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

class Point:
    """
    A point in a two-dimensional coordinate plane
    """
    
    def __init__(self, x, y):
        """
        Create a point with an x and y coordinate
        """
        self.x = x
        self.y = y
        
    def __str__(self):
        """
        Generate a string representation of a point
        """
        return "(" + str(self.x) + "," + str(self.y) + ")"


############################
# Part 1 - Rectangle Class
############################
class Rectangle:
    """
    A rectangle in a two-dimensional coordinate plane
    """
    
    def __init__(self, bottom_left_x, bottom_left_y, top_right_x, top_right_y):
        """
        Create a rectangle defined by its bottom left and top right corner
        coordinates
        """
        self.bottom_left = Point(bottom_left_x, bottom_left_y)
        self.top_right = Point(top_right_x, top_right_y)
        
    def __str__(self):
        """
        Generate a string representation of a rectangle
        """
        return ("Rectangle with corner coordinates " + 
                str(self.bottom_left) + ", " + str(self.top_right))
    
    def move(self, horizontal_translation, vertical_translation):
        """
        (Rectangle, int, int) -> None
        
        Alters the location of a rectangle by translating the coordinates
        of its bottom left and top right corner coordinates.
        """
        
        ## TODO complete the method
        pass
    
    def overlap(self, rectB):
        """
        (Rectangle, Rectangle) -> bool
        
        Checks whether two rectangles overlap
        """
        
        # check if one rectangle is on the left side of the other
        horizontal_clearance = ((self.bottom_left.x >= rectB.top_right.x) or
                                (self.top_right.x <= rectB.bottom_left.x))
        
        # check if one rectangle is above the other
        vertical_clearance = ((self.bottom_left.y >= rectB.top_right.y) or
                              (self.top_right.y <= rectB.bottom_left.y))
        
        return not (horizontal_clearance or vertical_clearance)


##############################
# Part 2 - Wind Turbine Class
##############################
class WindTurbine:
    """
    A wind turbine placed in a two-dimensional area
    """
    
    def __init__(self, id_number, placement_bottom_left_x, placement_bottom_left_y,
                 placement_top_right_x, placement_top_right_y):
        """
        Create a wind turbine
        """
        self.id_number = id_number
        self.placement = Rectangle(placement_bottom_left_x,placement_bottom_left_y,
                                   placement_top_right_x, placement_top_right_y)
        
        self.overlapping_turbines = []
    
    def __str__(self):
        """
        Generate a string representation of a WindTurbine object
        """
        return ("Wind Turbine ID: " + str(self.id_number) + 
                ", Placement: " + str(self.placement))

        
    def move(self, horizontal_translation, vertical_translation):
        """
        (WindTurbine, int, int) -> None
        
        Alters the location of a wind turbine by translating the coordinates
        of its bottom left and top right corner coordinates. After moving the 
        turbine, the overlapping turbine list should be reset to an empty
        list.
        
        The change in the x and y coordinates are specified by the
        horizontal_translation and vertical_translation parameters, respectively.
        """
        
        ## TODO complete the method
        pass
    
    def overlap(self, turbineB):
        """
        (WindTurbine, WindTurbine) -> bool
        
        Checks for overlap between a wind turbine and another turbine (turbineB).
        """
        ## TODO complete the method
        pass

    def validate_placement(self, turbines):
        """
        (WindTurbine, list of WindTurbines) -> None
        
        Check if the postion of a wind turbine is valid by checking for
        overlapping areas with all other wind turbines.
        """
        
        ## TODO complete the method
        pass


##########################################
# Part 3 - Testing Wind Turbine Placement
##########################################

def check_turbine_placements(turbines):
    """
    (list of WindTurbines) -> int
    
    Checks a list of wind turbines to identify turbines with invalid (overlapping)
    placements. The function should return the number of turbines with 
    invalid placements.
    
    All placements should be evaluated using the validate_placement method from
    the WindTurbine class.
    """
    
    ## TODO complete the function
    pass

For the Rectangle class, you will implement the following methods:
Move
For the Wind Turbine class, you will implement the following methods
move
●
overlap
validate_placement
You will write the following functions that analyze WindTurbine objects:
check_turbine_placements
Transcribed Image Text:For the Rectangle class, you will implement the following methods: Move For the Wind Turbine class, you will implement the following methods move ● overlap validate_placement You will write the following functions that analyze WindTurbine objects: check_turbine_placements
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Running Time of Application
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education