Question
Programming Language is in Java Create a class called Baron, which will construct objects which have a name as its instance variable. There must be
Programming Language is in Java
Create a class called Baron, which will construct objects which have a name as its instance variable. There must be a constructor for 0 and 1 parameter. There must be accessor and mutator methods for the instance variable where the method is named getName or setName. Lastly, there must be a method called compare, that takes a SINGLE Classy object as a parameter and compares the name of both objects and RETURNS A STRING of an appropriate message if it has the same name as the other object, or an appropriate message if it does not have the same name as the other object. You will have a main method within this class, where you will use each constructor you created to create two Barons, b1 and b2. You will then include the following code: System.out.println(b1.compare(b2)); b1.setName(new String(" [ENTER THE SAME NAME AS B2 HERE] "); //if you copy and paste this, the quotations may need to be replaced in the IDE System.out.println(b1.compare(b2));
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