2. Reply to another student’s post. Suggest another way to take advantage of the dynamic binding in that code

2. Reply to another student’s post. Suggest another way to take advantage of the dynamic binding in that code. Write the main method to demonstrate the correct functionality of the additions/modifications. As you reply to the other students, try to reply to a post that does not have a reply yet, and if not; try to reply to a post with a fewer number of replies.

Here is the response of the student

public class Week6 {

//Parent Class
static class Date{

//Method to
public void display() {

LocalDate current_date = LocalDate.now();

int CURRENT_YEAR = current_date.getYear();

System.out.println(“The current year is ” + CURRENT_YEAR);
System.exit(0);

}
}

//Child class of Date to display new message
static class Google extends Date{
public void display() {
System.out.println(“Google was founded in 1998”);
System.exit(0);
}
}

//Child class of Date to display new message
static class Yahoo extends Date{
public void display() {
System.out.println(“Yahoo was founded in 1994”);
System.exit(0);
}
}

//Child class of Date to display new message
static class Bing extends Date{
public void display() {
System.out.println(“Bing was founded in 2009”);
System.exit(0);
}
}

public static void main(String[] args) {

Scanner input = new Scanner(System.in);

//Greeting

System.out.print(“Want to know how old your favortie browsers are??\n”);

//Menu
System.out.println(“Press 1 for Google”);
System.out.println(“Press 2 for Yahoo”);
System.out.println(“Press 3 for Bing\n”);
System.out.println(“Or, Press any other number to view cuyrrent date and quit”);

//Ask user for input
System.out.print(“Enter your menu choice here: “);
int menuChoice = input.nextInt();

//if statements that override parent
if (menuChoice == 1) {
Date mChoice = new Google();
mChoice.display();
}
if (menuChoice == 2) {
Date mChoice = new Yahoo();
mChoice.display();
}
if (menuChoice == 3) {
Date mChoice = new Bing();
mChoice.display();
}
//Calls parent class method display
if (menuChoice <= 0 || menuChoice > 3) {
Date mChoice = new Date();
mChoice.display();
}

}
}

Complete Answer:

Get Instant Help in Homework Asap
Get Instant Help in Homework Asap
Calculate your paper price
Pages (550 words)
Approximate price: -
Open chat
1
Hello 👋
Thank you for choosing our assignment help service!
How can I help you?