Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
Java Program
Given partial codes of the Colored interface and Point class as the following:
//Colored interface
public interface Colored{
public String getColor();
}
//Point class
public class Point {
private int x;
private int y;
public Point() {
this(0, 0);
}
public Point(int x, int y) {
setLocation(x, y);
}
public boolean equals(Object o) {
if (o instanceof Point) {
Point other = (Point) o;
return x == other.x && y == other.y;
} else {
return false;
}
}
public void setLocation(int x, int y) {
this.x = x;
this.y = y;
}
public String toString() {
return "(" + x + ", " + y + ")";
}
}
Write ColoredPoint class so that implements the Colored interface and extends Point so that
Points have colors. Override toString method to print out the coordinates and color of the point,
override equals method so that it compares color as well. And write the necessary constructors,
accessors and mutators.
Write a client class and create objects of the ColoredPoint class. Print out the colored point and
compare if they are equal.
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps
Knowledge Booster
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
- Java Programingarrow_forwardConsider the following interface and class definitions: public interface A { public void m1(); public void m2(); } public interface B { public void m3(); } public interface C extends B { public void m1(); public void m2(); public void m4(); } public class X implements B { public void m3() { System.out.println("X m3"); } public void m1() { System.out.println("X m1"); } } public class Y implements A, B { public void m1() { System.out.println("Y m1"); } public void m2() { System.out.println("Y m2"); } public void m3() { System.out.println("Y m3"); } public void m4() { System.out.println(Y m4"); } } public class Z implements C { public void m1() { System.out.println("Z m1"); } public void m2() { System.out.println("Z m2"); } public void m3() { System.out.println("Z m3"); } public void m4() { System.out.println("Z m4"); } } Assume the following variables are created. X x = new X(); Y y = new Y(); Z z = new Z(); A a = new Y(); B b = new X(); B b2 = new Y(); C c = new Z(); Write…arrow_forwardJavascript Create an object, Gremlin, that extends the Monster interface and takes the same argument language. Gremlins inherits how a monster eats. Gremlins speaks differently. Gremlins replace each word in a sentence with its only known language, "gar". For example, if the sentence is "I like chicken", the speak() method will turn it into "gar gar gar". class Monster { constructor(language){ this.language = language; this.stomach = Array(); } // takes a food_item STRING and returns everything eaten so far ARRAY eat(food_item) { this.stomach.push(food_item); } // takes in a sentence STRING and returns the passed in sentence STRING with no change speak(sentence) { returnsentence; } }arrow_forward
- PLEASE ANSWER ALL QUESTIONS ON THE NEXT PAGE: class bookType { public: void setBookTitle(string s); //sets the bookTitle to s void setBookISBN(string ISBN); //sets the private member bookISBN to the parameter void setBookPrice(double cost); //sets the private member bookPrice to cost void setCopiesInStock(int noOfCopies); //sets the private member copiesInStock to noOfCopies void printInfo() const; //prints the bookTitle, bookISBN, the bookPrice and the copiesInStock string getBookISBN() const; //returns the bookISBN double getBookPrice() const; //returns the bookPrice int showQuantityInStock() const; //returns the quantity in stock void updateQuantity(int addBooks); //adds addBooks to the quantityInStock, so that the quantity in stock now has it original // value plus the parameter sent to this function private: string…arrow_forwardDefine an Animal method that updates the time to complete a particular behavior based on its name. Choose one of the following from the above choices (A, B, C or D within the code): public class Animal { // Other instance variables, constructors and methods // omitted for brevity // A public void updateTimeTakenForBehavior(String behaviorName, int timeToComplete) { for(int i = 0; i < this.behaviorList.length; i++) { Behavior tempBehavior = this.behaviorList[i]; if( tempBehavior.getBehaviorName().equals(behaviorName)) { tempBehavior.setTimeToComplete(timeToComplete); } } } // B public void updateTimeTakenForBehavior(String behaviorName, int timeToComplete) { for(int i = 0; i < this.behaviorList.length; i++) { Behavior tempBehavior = this.behaviorList[i]; if( !tempBehavior.getBehaviorName().equals(behaviorName) ) {…arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
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)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education