Challenge - Methods and interfaces
Here's a challenge to help you practice what you've learned about methods and interfaces. You'll also apply lessons from previous modules, such as creating and using your own package.
Create a package to manage an online store
Write a program that uses a custom package to manage accounts for an online store. Your challenge includes the following four elements:
Create a custom type called
Account
that includes the first and last name of the account owner. The type must also include the functionality toChangeName
.Create another custom type called
Employee
that includes a variable to store the number of credits as typefloat64
and that embeds theAccount
object. The type must also include the functionality toAddCredits
,RemoveCredits
, andCheckCredits
. You need to demonstrate that you can change the account name via theEmployee
object.Write a Stringer method to your
Account
object so that theEmployee
name can be printed in a format that includes the first and last name.Finally, write a program that consumes the package you created, and test all the functionality listed in this challenge. That is, the main program should change the name, print the name, add credit, remove credit, and check the balance.