Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

public class Computer { private String manufacturer; private String processor; private int ramSize; private int diskSize; private double processorSpeed; public Computer(String man, String pro, int

public class Computer { private String manufacturer; private String processor; private int ramSize; private int diskSize; private double processorSpeed;

public Computer(String man, String pro, int raSize, int diSize, double proSpeed) { manufacturer = man; processor = pro; ramSize = raSize; diskSize = diSize; processorSpeed = proSpeed; } public String getManufacturer() { return manufacturer; }

public String getProcessor() { return processor; }

public int getRamSize() { return ramSize; }

public int getDiskSize() { return diskSize; }

public double getProcessorSpeed() { return processorSpeed; } public boolean equals(Object obj){ //code here is hidden but correct }

} public class Tablet extends Computer{ private int length; private int width; private String operatingSystem;

public Tablet(String man, String pro, int raSize, int diSize, double proSpeed, int len, int wid, String os) { super(man, pro, raSize, diSize, proSpeed); length = len; width = wid; operatingSystem = os; }

public int getArea() { return length * width; }

public int getLength() { return length; }

public int getWidth() { return width; }

public String getOperatingSystem() { return operatingSystem; }

} }

Write an equals method for Tablet that will take in an Object obj and return true if the two classes are equal. Equals will return true if:

  1. the object passed is the same as the Tablet object performing the comparison

Or if both of the following are true:

  1. the object passed as a parameter is a Tablet
  2. all attributes among the Tablet objects (length, width, operating system, and Computer attributes) are equal.

@Override public boolean equals(Object obj) { }//end equals

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Object Oriented Databases Prentice Hall International Series In Computer Science

Authors: John G. Hughes

1st Edition

0136298745, 978-0136298748

More Books

Students also viewed these Databases questions

Question

Did the team members feel that their work mattered

Answered: 1 week ago

Question

2. What process will you put in place to address conflicts?

Answered: 1 week ago