From the course: Java Design Patterns: Behavioral Part 1
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Challenge: The Interpreter pattern - Java Tutorial
From the course: Java Design Patterns: Behavioral Part 1
Challenge: The Interpreter pattern
(upbeat electronic music) - (Instructor) Let's have a look at the next exercise. In this one, you're going to be working on an app that checks for simple grammar mistakes in a sentence. The structure of the app will be very similar to the variable checker app in the previous video. So, this app already has a main class with a main method. In the main method, we've got a screen called "context," which has a sentence we want to interpret, which says "this is a a sentence." You should use the interpreter pattern to create a syntax tree, then we check three things. First of all, the first letter of the first word should be an uppercase letter. Secondly, it should contain no repeated words. Although there are obviously some cases where a word might be repeated in a sentence, to keep things simple here, we're assuming this is always a mistake. And thirdly, the sentence should end with a period. This exercise is to…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.