Skip to content

Instantly share code, notes, and snippets.

View btforsythe's full-sized avatar

Brian T Forsythe btforsythe

View GitHub Profile
@btforsythe
btforsythe / Book.java
Created September 20, 2017 22:34
Library - now with searching!
package library;
public class Book {
private String title;
private String isbn;
private String author;
private String category;
public String getTitle() {
package library;
public class Book {
private String title;
private String isbn;
private String author;
private String category;
public String getTitle() {
@btforsythe
btforsythe / CreateFolders.groovy
Created August 25, 2017 23:27
Creating src directories with Groovy combinations()
def dirElements = [['src'],['main', 'test'],['java', 'resources']].combinations()
println "elements are $dirElements"
dirElements.each {
def dir = new File(it.join(File.separator))
println "checking for $dir"
if(!dir.exists()) {
@btforsythe
btforsythe / SubstringFinder.java
Created June 10, 2017 17:20
Longest common substring
package genes;
public class SubstringFinder {
private String firstString;
private String secondString;
public SubstringFinder(String parent, String child) {
this.firstString = parent;
this.secondString = child;
@btforsythe
btforsythe / SequenceFinder.java
Created June 10, 2017 17:08
Find the longest DNA sequence
package genes;
public class SequenceFinder {
private String parent;
private String child;
public SequenceFinder(String parent, String child) {
this.parent = parent;
this.child = child;
@btforsythe
btforsythe / StudentRecords.java
Created June 1, 2017 18:51
Student Records with and without Maps
package org.wecancodeit.objects.maps;
import java.util.ArrayList;
import java.util.List;
import org.wecancodeit.objects.students.Student;
public class StudentRecords {
public static void main(String[] args) {
@btforsythe
btforsythe / Numbers.java
Created May 30, 2017 18:02
Numbers problem
package org.wecancodeit.objects.arraylists;
import java.util.ArrayList;
public class Numbers {
public static void main(String[] args) {
ArrayList<Integer> numbers = new ArrayList<Integer>();
numbers.add(42);
@btforsythe
btforsythe / for-interview.md
Last active January 12, 2019 18:58
Java lesson plan for interview: for loops

Topics

Loops

  • What is a loop?
  • When would you use a loop?
  • Why would you use a loop?

For Loops

  • When to use a for loop
    • Counting
  • Iterating through an array/collection
@btforsythe
btforsythe / CustomersController.java
Created March 15, 2017 18:30
Example of controller test with mocks
package hello;
import javax.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
@Controller
import java.util.Arrays;
import java.util.List;
import java.util.function.Function;
public class Demo {
public static void main(String[] args) {
Grill grill = new Grill();
Cooker broilReference = () -> grill.broil("Steak");