// Arup Guha
// 4/28/2018
// Solution to 2016 AP Computer Science FR Question 2A,B

import java.util.*;

public class LogBook {

	private String machineId;
	private String description;

	// The AP people don't do it this way, but this is my favorite way to do this...
	public LogBook(String message) {
		StringTokenizer tok = new StringTokenizer(message,":");
		machineId = tok.nextToken();
		description = tok.nextToken();
	}

	public boolean containsWord(String keyword) {

		int idx = 0;

		// Go until no further substrings found.
		while (idx != -1) {

			// Get next substring.
			idx = description.indexOf(keyword, idx);

			// It's valid - now look left and right for spaces. Not the trickiness of the indexing!!!
			if (idx != -1) {
				boolean ok = (idx == 0 || description.charAt(idx-1) == ' ') &&
							 (idx +keyword.length() == description.length() || description.charAt(idx+keyword.length()) == ' ');
				if (ok) return ok;
				idx += keyword.length();
			}
		}

		// If we get here, we never found the keyword by itself.
		return false;
	}

	public String getMachineId() {
		return machineId;
	}

	public String getDescription() {
		return description;
	}

	public String toString() {
		return machineId+":"+description;
	}

	public static void main(String[] args) {

		LogBook mine = new LogBook("SERVER1:file is not read or writeable.");

		System.out.println("description contains file "+ mine.containsWord("file"));
		System.out.println("description contains not "+ mine.containsWord("not"));
		System.out.println("description contains write "+ mine.containsWord("write"));
		System.out.println("description contains able "+ mine.containsWord("able"));
		System.out.println("description contains writeable. "+ mine.containsWord("writeable."));
	}
}