1.5.5 How to Write a Wrapper Method

Wrapper methods are methods that are used to return primitive values from fields in another class or do math on a field and return the result.

An example of this would be wanting to increase the price of an item of a Food item. In the Food class, we can define a method with a return of type decimal and return a 30% increase in the price of the Food item.

Then in the MainWindow we can call that method on the MonkeyTail object and assign the result to a newPrice variable.

We can then use that variable to assign a new Price value to the MonkeyTail.

Once we execute that line of code, the MonkeyTail will have the new price.