Create two classes to represent the following two objects:
televisions and speakers. Include an initialize
function and several methods to
interact with your objects.
Given two Cartesian points (x 1, y 1) and (x 2, y 2), the slope of the line segment connecting them is given by the formula (y 2 - y 1)/(x 2 - x 1).
Write a class that represents a Cartesian point. Define a method
find_slope
that takes in a
Cartesian point object and finds the slope between the two points.
Test your class with the following:
(0,0) (3,4)
(2,3) (6,5)
(2,2) (2,7)
What happens in the last case? Why does that happen?
Define a class that compares two numbers and outputs the larger one. Test your solution.
Briefly explain the code illustrated in Example 9-10.
Write a Student
class that
contains a student’s name, gender, phone number, and exam score. It
should also include the initialize
,
accumulated_score
, and display
methods.
18.118.253.223