Question
FOR JAVA codes: Create an Interface called Printable, that defines 3 methods: toString() and display() and printToFile() [10 points] Update your class from your previous
FOR JAVA codes:
Create an Interface called Printable, that defines 3 methods: toString() and display() and printToFile() [10 points]
Update your class from your previous assignments to have the following
Implement the Comparable Interface [5 points]
Override to compareTo() method - (I'ts up to you to determine the best way to sort your objects) [20 points]
Implement the Printable interface - You will also need to implement all the methods, some of which you should already have. The printToFile() method should just simply print your data to a text file.[10 points]
In the driver class (the class with your main method), define your own generic static method called maxHighest()
It should have 3 generic parameters [10 points]
It will return the max highest item (based on their sorting order) of the 3 parameters [10 points]
In your main method, test the maxHighest() method by passing the following objects to it. It should print out the some text describing it as the 2nd highest item:
3 Strings [5 points]
3 Integers [5 points]
3 Objects of your Class from your previous assignments [5 points]
-------------------------------------------------------------------------------------------------------------------------------------------------
pervious Class code we need to update:
Shoes.java
public class Shoes {
// Declaring instance variables private int size; private String brand; private double price;
// Zero argumented constructor public Shoes() { this.size = 7; this.brand = "Red Tape"; this.price = 50; }
// Parameterized constructor public Shoes(int size, String brand, double price) { super(); this.size = size; this.brand = brand; this.price = price; }
// getters and setters
/* * This method will get the price of instance variable * * @params void * * @return double */ public int getSize() { return size; }
/* * This method will set the size of instance variable * * @params int * * @return void */ public void setSize(int size) { this.size = size; }
/* * This method will get the brand name of instance variable * * @params void * * @return String */ public String getBrand() { return brand; }
/* * This method will set the brand of instance variable * * @params String * * @return void */ public void setBrand(String brand) { this.brand = brand; }
/* * This method will return the price of instance variable * * @params void * * @return double */ public double getPrice() { return price; }
/* * This method will set the price of instance variable * * @params double * * @return void */ public void setPrice(double price) { this.price = price; }
/* * This method will display the values of instance variables * * @params void * * @return void */ void display() { System.out.println("Size :" + size); System.out.println("Brand :" + brand); System.out.println("Price :$" + price); }
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started