Create an interface named Turner, with a single method called turn(). Then creat
ID: 3568210 • Letter: C
Question
Create an interface named Turner, with a single method called turn(). Then create 4 classes:
1- Leaf: that implements turn(), which changes the color of the Leaf object and returns true. If for any reason it is unable to change color, it should return false (you can come up with a reason for failure). The new color can be determined at random.
2- Document: that implements turn(), which changes the page on the document to the next page and returns true. If the current page is the last page of the document, then it returns false. This class should have a method called returnIdDate(), which returns a String containing the ID of the Document and the date it was published.
3- Pancake: that implements turn(), which flips the pancake if it has not flipped before and returns true. If the pancake has already been flipped, then it returns false.
4- Think of one more objects that can use turn(). Create the class and implement the turn() method. Show your creativity.
Write an application, DemoTurners, which creates an array of 4 Turner objects and adds one object of each of these class types to it. Then demonstrate polymorphism by calling the turn() method on each object in a loop. Then print the Document object
Explanation / Answer
it's a question from java programming by joyce farrell
chapter 11 .............. 7th problem in exercises....
Njoy
please rate me
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.