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         """

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
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)
  
    
        self.bottom_right = Point(top_right_x, bottom_left_y)
        self.top_left = Point(bottom_left_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.
        """
        
        self.bottom_left.x += horizontal_translation
        self.bottom_left.y += vertical_translation
 
        self.top_right.x += horizontal_translation
        self.top_right.y += vertical_translation

 

        self.bottom_right.x += horizontal_translation
        self.bottom_right.y += vertical_translation

        self.top_left.x += horizontal_translation
        self.top_left.y += vertical_translation

        

    
    def overlap(self, rectB):
        """
        (Rectangle, Rectangle) -> bool
        
        Checks whether two rectangles overlap
        """

       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.r1 = Rectangle(placement_bottom_left_x,placement_bottom_left_y,
                                   placement_top_right_x, placement_top_right_y)
        
        self.overlapping_turbines = []
        self.placement = str(self.r1)
    
    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
        self.r1.move(horizontal_translation, vertical_translation) 
      
        self.placement = str(self.r1)
    
        self.overlapping_turbines = []  
      
      
    def overlap(self, turbineB)-> bool:
        """
        (WindTurbine, WindTurbine) -> bool
        
        Checks for overlap between a wind turbine and another turbine (turbineB).
        """
        return self.r1.overlap(turbineB)

    
    def validate_placement(self, turbineB): 
        """
        (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.
        """
        
        for t in turbineB:
            if(self.overlap(t)) and self!=t:
                self.overlapping_turbines.append(t)
                
        ## TODO complete the method
     


##########################################
# 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
    count =0
    for i in turbines:
        if (not i.validate_placement()):
            count+=1
    return count

 

(FIX ERRORS !)

[1/1] Test1.test_01
[1/1] Test1.test_02
[0/1] Test1.test_03
[0/1] Test1.test_04
[0/1] Test1.test_05
'Wind Turbine' object has no attribute 'top_right'
'Wind Turbine' object has no attribute 'top_right'
validate_placement() missing 1 required positional argument: 'turbines'
Passed
Passed
Error
Error
Error
Transcribed Image Text:[1/1] Test1.test_01 [1/1] Test1.test_02 [0/1] Test1.test_03 [0/1] Test1.test_04 [0/1] Test1.test_05 'Wind Turbine' object has no attribute 'top_right' 'Wind Turbine' object has no attribute 'top_right' validate_placement() missing 1 required positional argument: 'turbines' Passed Passed Error Error Error
Expert Solution
steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY