Please you can complete this part of my code almost done, I could not get the output. Please help me to fix this and add part 4 and 5. Part 4 instructions (please see image attached):  Implement the relationship between interface and the classes as shown in the diagram below. You must correctly implement appropriate methods in your classes based on abstraction and interface principles.  Part 5 instructions: . Inside the main() method of the Watch class, do the following: a) Create a new instance of the “AnalogWatch” class using the overloaded constructor and assign it to the object reference of type “Watch”. b) Create a new instance of the “DigitalWatch” class using the overloaded constructor and assign it to the object reference of type “Watch”. c) Display the content of both the objects. d) Display the current time using the two objects created above respectively   Code: public abstract class Watch {     //Data Fields     private String brand;     private String material;     private double price; //Default Constructor Watch(){              } //constructor Watch object with the specified objects:brand: String, material: String, price: double. Watch(String brand, String material, double price){     this.brand=brand;     this.material=material;     this.price=price;         } //Setter  & getters public void setBrand(String brand) {     this.brand = brand; } public String getBrand() {     return brand; } public void setMaterial(String material) {     this.material = material; } public String getMaterial() {     return material; } public void setPrice(double price) {     this.price = price; } public double getPrice() {     return price; } /*//Method Abstract public abstract boolean isWaterProof();*/ //toString @Override public String toString() {     return "\nWatch: "+"\nBrand: "+ brand +"\nMaterial: "+ material              + "\nPrice: "+ price;         }     //  Please help me with this part too-->Part 5 (Still Missing) //////////////////Main Method inside Parent Class  //////////////////////////////// public static void main(String[] args) { } }  public class AnalogWatch extends Watch {     //Data Fields     private int numbOfHands;     //Default Constructor     AnalogWatch (){              } ///Constructor AnalogWathc object with specified  brand, material, price, // numbOfHands.     AnalogWatch (String brand, String material, double price, int numbOfHands){     super(brand, material, price);     this.numbOfHands=numbOfHands;     } //Setters & getters     public void setNumbOfHands(int numbOfHands) {         this.numbOfHands = numbOfHands;     }     public int getNumbOfHands() {         return numbOfHands;     } //toString @Override  public String toString(){          return "\nWatch: "+"\nBrand: "+ super.getBrand() +"\nMaterial: "+ super.getMaterial()                  + "\nPrice: "+ super.getPrice()+"\nNumOfHands: "+ getNumbOfHands();      }      } public class DigitalWatch extends Watch {     //Data Fields     private int hourFormat;     //Default Constructor     DigitalWatch (){         super();     } //Constructor DigitalWatch object with specified specified  brand, material, price,     //hourFormat.     DigitalWatch (String brand, String material, double price, int hourFormat){         super(brand, material, price);         this.hourFormat=hourFormat;     } //Setters &Getters public void setHourFormat(int hourFormat) {         this.hourFormat = hourFormat;     } public int getHourFormat() {         return hourFormat;     }      //ToString  @Override public String toString() {     return "\nDigitalWatch: "+"\nBrand: "+ super.getBrand() +"\nMaterial: "+ super.getMaterial()      + "\nPrice: "+ super.getPrice()+"\nHourFormat: "+ getHourFormat();                  } }   --->This is the interface name Timer Code: import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; public interface Timer {     public String howtoChangeWatchTime();     public default String getCurrentTime() {         LocalDateTime now= LocalDateTime.now();         DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");         return now.format(formatter);     } } UML Diagram only for reference: Watch -brand: String -material: String -price: double +Watch() +Watch(brand: String, material: String, price: double) +setBrand(brand: String): void +getBrand(): String +setMaterial(material: String): void +getMaterial(): String +setPrice(brand: double): void +getPrice(): double +isWaterProof(): boolean +toString():String -->SecondUML: Child Class AnalogWatch -numOfHands: int +AnalogWatch() +AnalogWatch(brand: String, material: String, price: double, numOfHands: int) +setNumOfHands(numOfHands: int): void +getNumOfHands(): int +toString():String -->Third UML only for reference: Child class DigitalWatch -hourFormat: int +DigitalWatch() +DigitalWatch(brand: String, material: String, price: double, hourFormat: int) +sethourFormat(hourFormat: int): void +gethourFormat(): int +toString(): String

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

Please you can complete this part of my code almost done, I could not get the output. Please help me to fix this and add part 4 and 5.

Part 4 instructions (please see image attached):  Implement the relationship between interface and the classes as shown in the diagram below. You must correctly implement appropriate methods in your classes
based on abstraction and interface principles. 

Part 5 instructions: . Inside the main() method of the Watch class, do the following:
a) Create a new instance of the “AnalogWatch” class using the overloaded constructor
and assign it to the object reference of type “Watch”.
b) Create a new instance of the “DigitalWatch” class using the overloaded constructor
and assign it to the object reference of type “Watch”.
c) Display the content of both the objects.
d) Display the current time using the two objects created above respectively

 

Code:

public abstract class Watch {
    //Data Fields
    private String brand;
    private String material;
    private double price;
//Default Constructor
Watch(){
        
    }
//constructor Watch object with the specified objects:brand: String, material: String, price: double.
Watch(String brand, String material, double price){
    this.brand=brand;
    this.material=material;
    this.price=price;    
    }
//Setter  & getters
public void setBrand(String brand) {
    this.brand = brand;
}
public String getBrand() {
    return brand;
}
public void setMaterial(String material) {
    this.material = material;
}
public String getMaterial() {
    return material;
}
public void setPrice(double price) {
    this.price = price;
}
public double getPrice() {
    return price;
}
/*//Method Abstract
public abstract boolean isWaterProof();*/
//toString
@Override
public String toString() {
    return "\nWatch: "+"\nBrand: "+ brand +"\nMaterial: "+ material 
            + "\nPrice: "+ price;    
    }    

//  Please help me with this part too-->Part 5 (Still Missing)
//////////////////Main Method inside Parent Class  ////////////////////////////////
public static void main(String[] args) {

}

}

 public class AnalogWatch extends Watch {
    //Data Fields
    private int numbOfHands;
    //Default Constructor
    AnalogWatch (){
        
    }
///Constructor AnalogWathc object with specified  brand, material, price,
// numbOfHands.
    AnalogWatch (String brand, String material, double price, int numbOfHands){
    super(brand, material, price);
    this.numbOfHands=numbOfHands;
    }
//Setters & getters
    public void setNumbOfHands(int numbOfHands) {
        this.numbOfHands = numbOfHands;
    }
    public int getNumbOfHands() {
        return numbOfHands;
    }
//toString
@Override
 public String toString(){
         return "\nWatch: "+"\nBrand: "+ super.getBrand() +"\nMaterial: "+ super.getMaterial() 
                + "\nPrice: "+ super.getPrice()+"\nNumOfHands: "+ getNumbOfHands();    
 }
    
}

public class DigitalWatch extends Watch {
    //Data Fields
    private int hourFormat;
    //Default Constructor
    DigitalWatch (){
        super();
    }
//Constructor DigitalWatch object with specified specified  brand, material, price,
    //hourFormat.
    DigitalWatch (String brand, String material, double price, int hourFormat){
        super(brand, material, price);
        this.hourFormat=hourFormat;
    }
//Setters &Getters
public void setHourFormat(int hourFormat) {
        this.hourFormat = hourFormat;
    }
public int getHourFormat() {
        return hourFormat;
    }
    
//ToString 
@Override
public String toString() {
    return "\nDigitalWatch: "+"\nBrand: "+ super.getBrand() +"\nMaterial: "+ super.getMaterial() 
    + "\nPrice: "+ super.getPrice()+"\nHourFormat: "+ getHourFormat();    
            
}
}

 

--->This is the interface name Timer Code:

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public interface Timer {
    public String howtoChangeWatchTime();
    public default String getCurrentTime() {
        LocalDateTime now= LocalDateTime.now();
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        return now.format(formatter);
    }

}

UML Diagram only for reference:
Watch
-brand: String
-material: String
-price: double
+Watch()
+Watch(brand: String, material: String, price: double)
+setBrand(brand: String): void
+getBrand(): String
+setMaterial(material: String): void
+getMaterial(): String
+setPrice(brand: double): void
+getPrice(): double
+isWaterProof(): boolean
+toString():String

-->SecondUML: Child Class
AnalogWatch
-numOfHands: int
+AnalogWatch()
+AnalogWatch(brand: String, material: String, price: double, numOfHands: int)
+setNumOfHands(numOfHands: int): void
+getNumOfHands(): int
+toString():String

-->Third UML only for reference: Child class
DigitalWatch
-hourFormat: int
+DigitalWatch()
+DigitalWatch(brand: String, material: String, price: double, hourFormat: int)
+sethourFormat(hourFormat: int): void
+gethourFormat(): int
+toString(): String

Part 4. Implement the relationship between interface and the classes as shown in the
diagram below. You must correctly implement appropriate methods in your classes
based on abstraction and interface principles.
AnalogWatch
<<interface>>
Timer
Watch
2
Digital Watch
Transcribed Image Text:Part 4. Implement the relationship between interface and the classes as shown in the diagram below. You must correctly implement appropriate methods in your classes based on abstraction and interface principles. AnalogWatch <<interface>> Timer Watch 2 Digital Watch
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 6 steps with 1 images

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

This method does not work, please you can help me to add to this code Watch.java and how to add to the other codes AnalogWatch. java and DigitalWatch.java

 //Method Abstract
public abstract boolean isWaterProof();

 

 

Solution
Bartleby Expert
SEE SOLUTION
Knowledge Booster
Developing computer interface
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
Recommended textbooks for you
Database System Concepts
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)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education