For this studio, you will create a class to represent URLs as Java objects. You will do this using a test-driven approach.
Fork and clone the tdd-studio repository.
Review terminology for the following URL components at Wikipedia : protocol, domain, path.
Create two classes:
You will follow a test-driven approach to implement the requirements below. This means that for each requirement, you should write a test before writing any code for that requirement.
Use the red-green-refactor workflow:
Url constructor, and it should take a string (e.g. "https://launchcode.org/learn") and set domain, protocol, and path fields. Note that protocol and domain will not contain any / characters, but the path may.final and have getters but not setters."HTTPS://LAUNCHCODE.ORG" then calling getDomain() should return "launchcode.org".Url should override toString(), which should return a properly-formatted version of the URL (e.g. "https://launchcode.org/learn")IllegalArgumentException with an appropriate message.., -, or _Note
These requirements are not comprehensive of how a URL may be structured, but they encompass a large number of URLs you use on a daily basis.
If you implement the above requirements with time to spare, attempt to implement these as well: