Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In a certain style of object - oriented programming an object's methods aren't called directly. Instead, they must be invoked indirectly by calling a dispatch
In a certain style of objectoriented programming an object's methods aren't called directly. Instead, they must be invoked indirectly by calling a dispatch method that every object inherits from a toplevel Dispatcher class. This style allows us to control when and how methods are invoked. For example, assume savings is an instance of an Account class with deposit and withdraw methods. This is how clients would invoke these methods:
savings.dispatch
The dispatch method is implemented in the Dispatcher superclass: Dispatcher.java.
Complete the implementation of the dispatch method using reflection and test it using Bank.java.
Hints:
The parameter Object args is called a varargs parameter in Java. It means the user can give any number of inputs and these will be automatically lumped together as a single array of objects called args.
A class may have several methods with the same name overloading They are distinguished by the number and types of their parameters. So you will need to create a second array called argTypes that contains the types of the objects in args. Ie for full credit don't assume args contains one argument of type Double.
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