From the course: Java Design Patterns: Structural

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Challenge: The Adapter pattern

Challenge: The Adapter pattern - Java Tutorial

From the course: Java Design Patterns: Structural

Start my 1-month free trial

Challenge: The Adapter pattern

(upbeat music) - [Instructor] Let's have a look at our first challenge. This challenge is to refactor an app that checks the temperature in a city and prints out a warning if the temperature is too hot or too cold. So this app has a class called weather warnings... Which has one method called post warning. It checks if the temperature in a city is too low or too high, and if it is, then it prints out a warning message to the console. If not, it prints out a message saying that the temperature is okay. It also has an interface called city. This interface defines five methods. And there are two implementations of city called North American city and Asian city. These are very similar, but the North American city class uses Fahrenheit for temperature, and Asian city uses Celsius. Finally, the app has a main class with a main method in it. This method checks the temperature in different cities, and prints a message to the…

Contents