1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
garik1379 [7]
3 years ago
12

(Comparable interface) Write Rectangle class that implements the Comparable interface. Override the equals method so that two Re

ctangle objects are equal if their areas are the same.
Computers and Technology
1 answer:
Ray Of Light [21]3 years ago
6 0

Answer:

class Rectangle(object):

   def __init__(self, area):

       self.area = area

   def __eq__(self,other):

       return self.area == other.area

d = Rectangle(43)

e = Rectangle(23)

print(d == e)

Explanation:

The python program defines a class called Rectangle that accepts one argument 'area' and compare one instance of the object with another instance. The '__eq__' method helps to define the equality of the instance based on their area values. If the areas are equal, the equality statement returns true and false if not.

You might be interested in
A Windows user is locked out of her computer, and you must log into the local administrator account Helpdesk Admin. Which would
Damm [24]

Answer:

B is the correct answer

5 0
3 years ago
g Write a program that allows a user to input any text in your program. Using the tools that we have discussed, your program sho
Paladinen [302]

Answer:

Explanation:

The following function/program is written in Java. It asks the user for a sentence as an input and then splits that sentence into an array of words. Then it creates an arrayList for all of the unique words, comparing each word in the sentence with all of those in the ArrayList. If a word is found in the ArrayList it cancels the loop and moves on the next word in the sentence. Finally, it counts all of the unique words in the ArrayList and prints that total to the screen.

public static void uniqueWords() {

       Scanner in = new Scanner(System.in);

       System.out.println("Enter a sentence:");

       String sentence = in.nextLine();

       String words[] = sentence.split(" ");

       ArrayList<String> uniqueWords = new ArrayList<>();

       for (int x = 0; x < words.length; x++) {

           boolean exists = false;

           for (int i = 0; i < uniqueWords.size(); i++) {

               if (words[x].equals(uniqueWords.get(i))) {

                   exists = true;

                   break;

               }

           }

           if (exists == false) {

               uniqueWords.add(words[x]);

           }

       }

       System.out.println(uniqueWords.size());

   }

5 0
3 years ago
You are planning on attending college after graduating from high school. you want to become a middle school math teacher in your
andreyandreev [35.5K]
If they have a good program. Ask friends and families. But also look at cost so if your out of state you can still afford to come home.
7 0
3 years ago
Read 2 more answers
Which of the following activities is primarily an employer’s responsibility to help prevent workplace violence?
Lera25 [3.4K]
I believe that's b, i'm not 100% sure though
5 0
3 years ago
Read 2 more answers
Which of the following are wise entrepreneurial decisions or concepts? Check all of the boxes that apply.
Artyom0805 [142]

Answer:

a b e d f

Explanation:

8 0
3 years ago
Read 2 more answers
Other questions:
  • What is the purpose of news services
    13·1 answer
  • Editing and sorting the data file are steps performed during the ________ stage in the data processing cycle
    5·1 answer
  • A switch is closed, and a lamp turns on.The switch is opened, the lamp turns off. eXplain what is meant by these two statements.
    10·1 answer
  • Seth is considering advertising his business using paid search results.What do you think makes paid search advertising so effect
    11·2 answers
  • Susan's monthly goal to open five new customer
    10·1 answer
  • What is the difference between the throw statement and the throws clause?
    10·1 answer
  • What is the correct html element for playing audio files?
    11·1 answer
  • Sally is editing her science report about living things. She needs to copy a paragraph from her original report.
    13·1 answer
  • Which devices are likely to include a computer? Select 3 options.
    7·1 answer
  • A retailer is able to track which products draw the most attention from its customers through the use of 5g-enabled motion senso
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!