@@ -0,0 +1,74 @@
import java.util.Arrays;

public class Sandwich_Pt1 {


public static void main(String[] args) {
System.out.println(Arrays.toString("I really really like really red apples".split("really")));
System.out.println(Arrays.toString("I like red apples".split(" ")));
//test for Part 1
System.out.println(sandwich_Pt1("breadmeatleetuceeadmayoketchuead"));
System.out.println(sandwich_Pt1("breadbread"));
System.out.println(sandwich_Pt1("bread"));
System.out.println(sandwich_Pt1("breadsomethingbreadmeatbread"));
System.out.println(sandwich_Pt1("cheesebreadsomethingbread"));
System.out.println(sandwich_Pt1("cheesebreadsomethingbreadotherstuff"));
System.out.println(sandwich_Pt1("breadbreadsomethingbread"));
//test for Part 2
System.out.println(sandwich_Pt2("bread mayo bread mayo bread"));
System.out.println(sandwich_Pt2("something bread mayo bread mayo bread"));
System.out.println(sandwich_Pt2("breadbreadbread"));
//String.split();
//It's a method that acts on a string, <StringName>.split(<String sp>);
//Where sp is the string where the string splits
//And it returns an array
// Example: "I like apples!".split(" ");
// it will split at spaces and return an array of ["I","like","apples!"]
// Example 2: "I really like really red apples"split("really")
// it will split at the word "really" and return an array of ["I "," like "," apples!"]

//play around with String.split! what happens if you "I reallyreally like apples".split("really") ?


//Your task:
/*Write a method that take in a string like "applespineapplesbreadlettustomatobaconmayohambreadcheese" describing a sandwich
* use String.split to split up the sandwich by the word "bread" and return what's in the middle of the sandwich and ignores what's on the outside
* What if it's a fancy sandwich with multiple pieces of bread?
*/


//Your task pt 2:
/*Write a method that take in a string like "apples pineapples bread lettus tomato bacon mayo ham bread cheese" describing a sandwich
* use String.split to split up the sandwich at the spaces, " ", and return what's in the middle of the sandwich and ignores what's on the outside
* Again, what if it's a fancy sandwich with multiple pieces of bread?
*/



}
public static String sandwich_Pt1(String messedUpSandwich){
if(messedUpSandwich.indexOf("bread")<0||messedUpSandwich.indexOf("bread")==messedUpSandwich.lastIndexOf("bread"))
return "Not a sandwich!";
String orderedSandwich=messedUpSandwich.substring(messedUpSandwich.indexOf("bread"), messedUpSandwich.lastIndexOf("bread"));
String split[] =orderedSandwich.split("bread");
String answer="";
for(int i=1;i<split.length;i++)
answer=answer+split[i];
if (answer.trim().length()==0)
return "Not a sandwich!";
return answer;
}
public static String sandwich_Pt2(String messedUpSandwich){
if(messedUpSandwich.indexOf("bread")<0||messedUpSandwich.indexOf("bread")==messedUpSandwich.lastIndexOf("bread"))
return "Not a sandwich!";
String orderedSandwich=messedUpSandwich.substring(messedUpSandwich.indexOf("bread"), messedUpSandwich.lastIndexOf("bread"));
String split[] =orderedSandwich.split(" ");
String answer="";
for(int i=0;i<split.length;i++)
answer=answer+split[i];
if (answer.trim().equals("breadbread")||answer.trim().equals("breadbreadbread"))
return "Not a sandwich!";
return answer;
}

}
@@ -0,0 +1,72 @@
import java.util.Arrays;

public class Sandwich_Pt1 {


public static void main(String[] args) {
System.out.println(Arrays.toString("I really really like really red apples".split("really")));
System.out.println(Arrays.toString("I like red apples".split(" ")));
//test for Part 1
System.out.println(sandwich_Pt1("breadmeatleetuceeadmayoketchuead"));
System.out.println(sandwich_Pt1("breadbread"));
System.out.println(sandwich_Pt1("bread"));
System.out.println(sandwich_Pt1("breadsomethingbreadmeatbread"));
System.out.println(sandwich_Pt1("cheesebreadsomethingbread"));
System.out.println(sandwich_Pt1("cheesebreadsomethingbreadotherstuff"));
System.out.println(sandwich_Pt1("breadbreadsomethingbread"));
//test for Part 2
System.out.println(sandwich_Pt2("bread mayo bread mayo bread"));
//String.split();
//It's a method that acts on a string, <StringName>.split(<String sp>);
//Where sp is the string where the string splits
//And it returns an array
// Example: "I like apples!".split(" ");
// it will split at spaces and return an array of ["I","like","apples!"]
// Example 2: "I really like really red apples"split("really")
// it will split at the word "really" and return an array of ["I "," like "," apples!"]

//play around with String.split! what happens if you "I reallyreally like apples".split("really") ?


//Your task:
/*Write a method that take in a string like "applespineapplesbreadlettustomatobaconmayohambreadcheese" describing a sandwich
* use String.split to split up the sandwich by the word "bread" and return what's in the middle of the sandwich and ignores what's on the outside
* What if it's a fancy sandwich with multiple pieces of bread?
*/


//Your task pt 2:
/*Write a method that take in a string like "apples pineapples bread lettus tomato bacon mayo ham bread cheese" describing a sandwich
* use String.split to split up the sandwich at the spaces, " ", and return what's in the middle of the sandwich and ignores what's on the outside
* Again, what if it's a fancy sandwich with multiple pieces of bread?
*/



}
public static String sandwich_Pt1(String messedUpSandwich){
if(messedUpSandwich.indexOf("bread")<0||messedUpSandwich.indexOf("bread")==messedUpSandwich.lastIndexOf("bread"))
return "Not a sandwich!";
String orderedSandwich=messedUpSandwich.substring(messedUpSandwich.indexOf("bread"), messedUpSandwich.lastIndexOf("bread"));
String split[] =orderedSandwich.split("bread");
String answer="";
for(int i=1;i<split.length;i++)
answer=answer+split[i];
if (answer.trim().length()==0)
return "Not a sandwich!";
return answer;
}
public static String sandwich_Pt2(String messedUpSandwich){
if(messedUpSandwich.indexOf("bread")<0||messedUpSandwich.indexOf("bread")==messedUpSandwich.lastIndexOf("bread"))
return "Not a sandwich!";
String orderedSandwich=messedUpSandwich.substring(messedUpSandwich.indexOf(" "), messedUpSandwich.lastIndexOf("bread"));
String split[] =orderedSandwich.split("bread");
String answer="";
for(int i=0;i<split.length;i++)
answer=answer+split[i];
if (answer.trim().equals("breadbread")||answer.trim().equals("breadbreadbread"))
return "Not a sandwich!";
return answer;
}

}
@@ -0,0 +1,73 @@
import java.util.Arrays;

public class Sandwich_Pt1 {


public static void main(String[] args) {
System.out.println(Arrays.toString("I really really like really red apples".split("really")));
System.out.println(Arrays.toString("I like red apples".split(" ")));
//test for Part 1
System.out.println(sandwich_Pt1("breadmeatleetuceeadmayoketchuead"));
System.out.println(sandwich_Pt1("breadbread"));
System.out.println(sandwich_Pt1("bread"));
System.out.println(sandwich_Pt1("breadsomethingbreadmeatbread"));
System.out.println(sandwich_Pt1("cheesebreadsomethingbread"));
System.out.println(sandwich_Pt1("cheesebreadsomethingbreadotherstuff"));
System.out.println(sandwich_Pt1("breadbreadsomethingbread"));
//test for Part 2
System.out.println(sandwich_Pt2("bread mayo bread mayo bread"));
System.out.println(sandwich_Pt2("something bread mayo bread mayo bread"));
//String.split();
//It's a method that acts on a string, <StringName>.split(<String sp>);
//Where sp is the string where the string splits
//And it returns an array
// Example: "I like apples!".split(" ");
// it will split at spaces and return an array of ["I","like","apples!"]
// Example 2: "I really like really red apples"split("really")
// it will split at the word "really" and return an array of ["I "," like "," apples!"]

//play around with String.split! what happens if you "I reallyreally like apples".split("really") ?


//Your task:
/*Write a method that take in a string like "applespineapplesbreadlettustomatobaconmayohambreadcheese" describing a sandwich
* use String.split to split up the sandwich by the word "bread" and return what's in the middle of the sandwich and ignores what's on the outside
* What if it's a fancy sandwich with multiple pieces of bread?
*/


//Your task pt 2:
/*Write a method that take in a string like "apples pineapples bread lettus tomato bacon mayo ham bread cheese" describing a sandwich
* use String.split to split up the sandwich at the spaces, " ", and return what's in the middle of the sandwich and ignores what's on the outside
* Again, what if it's a fancy sandwich with multiple pieces of bread?
*/



}
public static String sandwich_Pt1(String messedUpSandwich){
if(messedUpSandwich.indexOf("bread")<0||messedUpSandwich.indexOf("bread")==messedUpSandwich.lastIndexOf("bread"))
return "Not a sandwich!";
String orderedSandwich=messedUpSandwich.substring(messedUpSandwich.indexOf("bread"), messedUpSandwich.lastIndexOf("bread"));
String split[] =orderedSandwich.split("bread");
String answer="";
for(int i=1;i<split.length;i++)
answer=answer+split[i];
if (answer.trim().length()==0)
return "Not a sandwich!";
return answer;
}
public static String sandwich_Pt2(String messedUpSandwich){
if(messedUpSandwich.indexOf("bread")<0||messedUpSandwich.indexOf("bread")==messedUpSandwich.lastIndexOf("bread"))
return "Not a sandwich!";
String orderedSandwich=messedUpSandwich.substring(messedUpSandwich.indexOf(" "), messedUpSandwich.lastIndexOf("bread"));
String split[] =orderedSandwich.split("bread");
String answer="";
for(int i=0;i<split.length;i++)
answer=answer+split[i];
if (answer.trim().equals("breadbread")||answer.trim().equals("breadbreadbread"))
return "Not a sandwich!";
return answer;
}

}
@@ -0,0 +1,77 @@
import java.util.Arrays;

public class Sandwich_Pt1 {


public static void main(String[] args) {
System.out.println(Arrays.toString("I really really like really red apples".split("really")));
System.out.println(Arrays.toString("I like red apples".split(" ")));
//test for Part 1
System.out.println(sandwich_Pt1("breadmeatleetuceeadmayoketchuead"));
System.out.println(sandwich_Pt1("breadbread"));
System.out.println(sandwich_Pt1("bread"));
System.out.println(sandwich_Pt1("breadsomethingbreadmeatbread"));
System.out.println(sandwich_Pt1("cheesebreadsomethingbread"));
System.out.println(sandwich_Pt1("cheesebreadsomethingbreadotherstuff"));
System.out.println(sandwich_Pt1("breadbreadsomethingbread"));
//test for Part 2
System.out.println(sandwich_Pt2("bread mayo bread mayo bread"));
System.out.println(sandwich_Pt2("something bread mayo bread mayo bread"));
System.out.println(sandwich_Pt2("breadbreadbread"));
System.out.println(sandwich_Pt2("bread something bread bread"));
System.out.println(sandwich_Pt2("something bread bread bread"));
//String.split();
//It's a method that acts on a string, <StringName>.split(<String sp>);
//Where sp is the string where the string splits
//And it returns an array
// Example: "I like apples!".split(" ");
// it will split at spaces and return an array of ["I","like","apples!"]
// Example 2: "I really like really red apples"split("really")
// it will split at the word "really" and return an array of ["I "," like "," apples!"]

//play around with String.split! what happens if you "I reallyreally like apples".split("really") ?


//Your task:
/*Write a method that take in a string like "applespineapplesbreadlettustomatobaconmayohambreadcheese" describing a sandwich
* use String.split to split up the sandwich by the word "bread" and return what's in the middle of the sandwich and ignores what's on the outside
* What if it's a fancy sandwich with multiple pieces of bread?
*/


//Your task pt 2:
/*Write a method that take in a string like "apples pineapples bread lettus tomato bacon mayo ham bread cheese" describing a sandwich
* use String.split to split up the sandwich at the spaces, " ", and return what's in the middle of the sandwich and ignores what's on the outside
* Again, what if it's a fancy sandwich with multiple pieces of bread?
*/



}
public static String sandwich_Pt1(String messedUpSandwich){
if(messedUpSandwich.indexOf("bread")<0||messedUpSandwich.indexOf("bread")==messedUpSandwich.lastIndexOf("bread"))
return "Not a sandwich!";
String orderedSandwich=messedUpSandwich.substring(messedUpSandwich.indexOf("bread"), messedUpSandwich.lastIndexOf("bread"));
String split[] =orderedSandwich.split("bread");
String answer="";
for(int i=1;i<split.length;i++)
answer=answer+split[i];
if (answer.trim().length()==0)
return "Not a sandwich!";
return answer;
}
public static String sandwich_Pt2(String messedUpSandwich){
if(messedUpSandwich.indexOf("bread")<0||messedUpSandwich.indexOf("bread")==messedUpSandwich.lastIndexOf("bread"))
return "Not a sandwich!";
String orderedSandwich=messedUpSandwich.substring(messedUpSandwich.indexOf("bread"), messedUpSandwich.lastIndexOf("bread"));
String split[] =orderedSandwich.split(" ");
String answer="";
for(int i=0;i<split.length;i++)
if(!split[i].equals("bread"))
answer=answer+split[i];
if (answer.trim().equals("breadbread")||answer.trim().equals("breadbreadbread"))
return "Not a sandwich!";
return answer;
}

}
@@ -0,0 +1,58 @@
import java.util.Arrays;

public class Sandwich_Pt1 {


public static void main(String[] args) {
System.out.println(Arrays.toString("I really really like really red apples".split("really")));
System.out.println(Arrays.toString("I like red apples".split(" ")));
String test="breadmeatleetuceeadmayoketchuead";
System.out.println(sandwich(test));
System.out.println(sandwich("breadbread"));
System.out.println(sandwich("bread"));
System.out.println(sandwich("breadsomethingbreadmeatbread"));
System.out.println(sandwich("cheesebreadsomethingbread"));
System.out.println(sandwich("cheesebreadsomethingbreadotherstuff"));
System.out.println(sandwich("breadbreadsomethingbread"));
//String.split();
//It's a method that acts on a string, <StringName>.split(<String sp>);
//Where sp is the string where the string splits
//And it returns an array
// Example: "I like apples!".split(" ");
// it will split at spaces and return an array of ["I","like","apples!"]
// Example 2: "I really like really red apples"split("really")
// it will split at the word "really" and return an array of ["I "," like "," apples!"]

//play around with String.split! what happens if you "I reallyreally like apples".split("really") ?


//Your task:
/*Write a method that take in a string like "applespineapplesbreadlettustomatobaconmayohambreadcheese" describing a sandwich
* use String.split to split up the sandwich by the word "bread" and return what's in the middle of the sandwich and ignores what's on the outside
* What if it's a fancy sandwich with multiple pieces of bread?
*/


//Your task pt 2:
/*Write a method that take in a string like "apples pineapples bread lettus tomato bacon mayo ham bread cheese" describing a sandwich
* use String.split to split up the sandwich at the spaces, " ", and return what's in the middle of the sandwich and ignores what's on the outside
* Again, what if it's a fancy sandwich with multiple pieces of bread?
*/



}
public static String sandwich(String messedUpSandwich){
if(messedUpSandwich.indexOf("bread")<0||messedUpSandwich.indexOf("bread")==messedUpSandwich.lastIndexOf("bread"))
return "Not a sandwich!";
String orderedSandwich=messedUpSandwich.substring(messedUpSandwich.indexOf("bread"), messedUpSandwich.lastIndexOf("bread"));
String split[] =orderedSandwich.split("bread");
String answer="";
for(int i=1;i<split.length;i++)
answer=answer+split[i];
if (answer.trim().length()==0)
return "Not a sandwich!";
return answer;
}

}
@@ -0,0 +1,72 @@
import java.util.Arrays;

public class Sandwich_Pt1 {


public static void main(String[] args) {
System.out.println(Arrays.toString("I really really like really red apples".split("really")));
System.out.println(Arrays.toString("I like red apples".split(" ")));
//test for Part 1
System.out.println(sandwich_Pt1("breadmeatleetuceeadmayoketchuead"));
System.out.println(sandwich_Pt1("breadbread"));
System.out.println(sandwich_Pt1("bread"));
System.out.println(sandwich_Pt1("breadsomethingbreadmeatbread"));
System.out.println(sandwich_Pt1("cheesebreadsomethingbread"));
System.out.println(sandwich_Pt1("cheesebreadsomethingbreadotherstuff"));
System.out.println(sandwich_Pt1("breadbreadsomethingbread"));
//test for Part 2
System.out.println(sandwich_Pt2("bread mayo bread mayo bread"));
//String.split();
//It's a method that acts on a string, <StringName>.split(<String sp>);
//Where sp is the string where the string splits
//And it returns an array
// Example: "I like apples!".split(" ");
// it will split at spaces and return an array of ["I","like","apples!"]
// Example 2: "I really like really red apples"split("really")
// it will split at the word "really" and return an array of ["I "," like "," apples!"]

//play around with String.split! what happens if you "I reallyreally like apples".split("really") ?


//Your task:
/*Write a method that take in a string like "applespineapplesbreadlettustomatobaconmayohambreadcheese" describing a sandwich
* use String.split to split up the sandwich by the word "bread" and return what's in the middle of the sandwich and ignores what's on the outside
* What if it's a fancy sandwich with multiple pieces of bread?
*/


//Your task pt 2:
/*Write a method that take in a string like "apples pineapples bread lettus tomato bacon mayo ham bread cheese" describing a sandwich
* use String.split to split up the sandwich at the spaces, " ", and return what's in the middle of the sandwich and ignores what's on the outside
* Again, what if it's a fancy sandwich with multiple pieces of bread?
*/



}
public static String sandwich_Pt1(String messedUpSandwich){
if(messedUpSandwich.indexOf("bread")<0||messedUpSandwich.indexOf("bread")==messedUpSandwich.lastIndexOf("bread"))
return "Not a sandwich!";
String orderedSandwich=messedUpSandwich.substring(messedUpSandwich.indexOf("bread"), messedUpSandwich.lastIndexOf("bread"));
String split[] =orderedSandwich.split("bread");
String answer="";
for(int i=1;i<split.length;i++)
answer=answer+split[i];
if (answer.trim().length()==0)
return "Not a sandwich!";
return answer;
}
public static String sandwich_Pt2(String messedUpSandwich){
if(messedUpSandwich.indexOf("bread")<0||messedUpSandwich.indexOf("bread")==messedUpSandwich.lastIndexOf("bread"))
return "Not a sandwich!";
String orderedSandwich=messedUpSandwich.substring(messedUpSandwich.indexOf(" "), messedUpSandwich.lastIndexOf("bread"));
String split[] =orderedSandwich.split("bread");
String answer="";
for(int i=1;i<split.length;i++)
answer=answer+split[i];
if (answer.trim().equals("breadbread")||answer.trim().equals("breadbreadbread"))
return "Not a sandwich!";
return answer;
}

}
@@ -0,0 +1,77 @@
import java.util.Arrays;

public class Sandwich_Pt1 {


public static void main(String[] args) {
System.out.println(Arrays.toString("I really really like really red apples".split("really")));
System.out.println(Arrays.toString("I like red apples".split(" ")));
//test for Part 1
System.out.println(sandwich_Pt1("breadmeatleetuceeadmayoketchuead"));
System.out.println(sandwich_Pt1("breadbread"));
System.out.println(sandwich_Pt1("bread"));
System.out.println(sandwich_Pt1("breadsomethingbreadmeatbread"));
System.out.println(sandwich_Pt1("cheesebreadsomethingbread"));
System.out.println(sandwich_Pt1("cheesebreadsomethingbreadotherstuff"));
System.out.println(sandwich_Pt1("breadbreadsomethingbread"));
//test for Part 2
System.out.println(sandwich_Pt2("bread mayo bread mayo bread"));
System.out.println(sandwich_Pt2("something bread mayo bread mayo bread"));
System.out.println(sandwich_Pt2("breadbreadbread"));
System.out.println(sandwich_Pt2("bread something bread bread"));
System.out.println(sandwich_Pt2("somethingbread bread bread"));
//String.split();
//It's a method that acts on a string, <StringName>.split(<String sp>);
//Where sp is the string where the string splits
//And it returns an array
// Example: "I like apples!".split(" ");
// it will split at spaces and return an array of ["I","like","apples!"]
// Example 2: "I really like really red apples"split("really")
// it will split at the word "really" and return an array of ["I "," like "," apples!"]

//play around with String.split! what happens if you "I reallyreally like apples".split("really") ?


//Your task:
/*Write a method that take in a string like "applespineapplesbreadlettustomatobaconmayohambreadcheese" describing a sandwich
* use String.split to split up the sandwich by the word "bread" and return what's in the middle of the sandwich and ignores what's on the outside
* What if it's a fancy sandwich with multiple pieces of bread?
*/


//Your task pt 2:
/*Write a method that take in a string like "apples pineapples bread lettus tomato bacon mayo ham bread cheese" describing a sandwich
* use String.split to split up the sandwich at the spaces, " ", and return what's in the middle of the sandwich and ignores what's on the outside
* Again, what if it's a fancy sandwich with multiple pieces of bread?
*/



}
public static String sandwich_Pt1(String messedUpSandwich){
if(messedUpSandwich.indexOf("bread")<0||messedUpSandwich.indexOf("bread")==messedUpSandwich.lastIndexOf("bread"))
return "Not a sandwich!";
String orderedSandwich=messedUpSandwich.substring(messedUpSandwich.indexOf("bread"), messedUpSandwich.lastIndexOf("bread"));
String split[] =orderedSandwich.split("bread");
String answer="";
for(int i=1;i<split.length;i++)
answer=answer+split[i];
if (answer.trim().length()==0)
return "Not a sandwich!";
return answer;
}
public static String sandwich_Pt2(String messedUpSandwich){
if(messedUpSandwich.indexOf("bread")<0||messedUpSandwich.indexOf("bread")==messedUpSandwich.lastIndexOf("bread"))
return "Not a sandwich!";
String orderedSandwich=messedUpSandwich.substring(messedUpSandwich.indexOf("bread"), messedUpSandwich.lastIndexOf("bread"));
String split[] =orderedSandwich.split(" ");
String answer="";
for(int i=0;i<split.length;i++)
if(!split[i].equals("bread"))
answer=answer+split[i];
if (answer.trim().equals("breadbread")||answer.trim().equals("breadbreadbread"))
return "Not a sandwich!";
return answer;
}

}
@@ -0,0 +1,78 @@
import java.util.Arrays;

public class Sandwich_Pt1 {


public static void main(String[] args) {
System.out.println(Arrays.toString("I really really like really red apples".split("really")));
System.out.println(Arrays.toString("I like red apples".split(" ")));
//test for Part 1
System.out.println(sandwich_Pt1("breadmeatleetuceeadmayoketchuead"));
System.out.println(sandwich_Pt1("breadbread"));
System.out.println(sandwich_Pt1("bread"));
System.out.println(sandwich_Pt1("breadsomethingbreadmeatbread"));
System.out.println(sandwich_Pt1("cheesebreadsomethingbread"));
System.out.println(sandwich_Pt1("cheesebreadsomethingbreadotherstuff"));
System.out.println(sandwich_Pt1("breadbreadsomethingbread"));
System.out.println();
//test for Part 2
System.out.println(sandwich_Pt2("bread mayo bread mayo bread"));
System.out.println(sandwich_Pt2("something bread mayo bread mayo bread"));
System.out.println(sandwich_Pt2("bread bread bread"));
System.out.println(sandwich_Pt2("bread something bread bread"));
System.out.println(sandwich_Pt2("something bread bread bread"));
//String.split();
//It's a method that acts on a string, <StringName>.split(<String sp>);
//Where sp is the string where the string splits
//And it returns an array
// Example: "I like apples!".split(" ");
// it will split at spaces and return an array of ["I","like","apples!"]
// Example 2: "I really like really red apples"split("really")
// it will split at the word "really" and return an array of ["I "," like "," apples!"]

//play around with String.split! what happens if you "I reallyreally like apples".split("really") ?


//Your task:
/*Write a method that take in a string like "applespineapplesbreadlettustomatobaconmayohambreadcheese" describing a sandwich
* use String.split to split up the sandwich by the word "bread" and return what's in the middle of the sandwich and ignores what's on the outside
* What if it's a fancy sandwich with multiple pieces of bread?
*/


//Your task pt 2:
/*Write a method that take in a string like "apples pineapples bread lettus tomato bacon mayo ham bread cheese" describing a sandwich
* use String.split to split up the sandwich at the spaces, " ", and return what's in the middle of the sandwich and ignores what's on the outside
* Again, what if it's a fancy sandwich with multiple pieces of bread?
*/



}
public static String sandwich_Pt1(String messedUpSandwich){
if(messedUpSandwich.indexOf("bread")<0||messedUpSandwich.indexOf("bread")==messedUpSandwich.lastIndexOf("bread"))
return "Not a sandwich!";
String orderedSandwich=messedUpSandwich.substring(messedUpSandwich.indexOf("bread"), messedUpSandwich.lastIndexOf("bread"));
String split[] =orderedSandwich.split("bread");
String answer="";
for(int i=1;i<split.length;i++)
answer=answer+split[i];
if (answer.trim().length()==0)
return "Not a sandwich!";
return answer;
}
public static String sandwich_Pt2(String messedUpSandwich){
if(messedUpSandwich.indexOf("bread")<0||messedUpSandwich.indexOf("bread")==messedUpSandwich.lastIndexOf("bread"))
return "Not a sandwich!";
String orderedSandwich=messedUpSandwich.substring(messedUpSandwich.indexOf("bread"), messedUpSandwich.lastIndexOf("bread"));
String split[] =orderedSandwich.split(" ");
String answer="";
for(int i=0;i<split.length;i++)
if(!split[i].equals("bread"))
answer=answer+split[i];
if (answer.trim().length()==0)
return "Not a sandwich!";
return answer;
}

}
@@ -0,0 +1,77 @@
import java.util.Arrays;

public class Sandwich_Pt1 {


public static void main(String[] args) {
System.out.println(Arrays.toString("I really really like really red apples".split("really")));
System.out.println(Arrays.toString("I like red apples".split(" ")));
//test for Part 1
System.out.println(sandwich_Pt1("breadmeatleetuceeadmayoketchuead"));
System.out.println(sandwich_Pt1("breadbread"));
System.out.println(sandwich_Pt1("bread"));
System.out.println(sandwich_Pt1("breadsomethingbreadmeatbread"));
System.out.println(sandwich_Pt1("cheesebreadsomethingbread"));
System.out.println(sandwich_Pt1("cheesebreadsomethingbreadotherstuff"));
System.out.println(sandwich_Pt1("breadbreadsomethingbread"));
//test for Part 2
System.out.println(sandwich_Pt2("bread mayo bread mayo bread"));
System.out.println(sandwich_Pt2("something bread mayo bread mayo bread"));
System.out.println(sandwich_Pt2("breadbreadbread"));
System.out.println(sandwich_Pt2("bread something bread bread"));
System.out.println(sandwich_Pt2(" something bread bread bread"));
//String.split();
//It's a method that acts on a string, <StringName>.split(<String sp>);
//Where sp is the string where the string splits
//And it returns an array
// Example: "I like apples!".split(" ");
// it will split at spaces and return an array of ["I","like","apples!"]
// Example 2: "I really like really red apples"split("really")
// it will split at the word "really" and return an array of ["I "," like "," apples!"]

//play around with String.split! what happens if you "I reallyreally like apples".split("really") ?


//Your task:
/*Write a method that take in a string like "applespineapplesbreadlettustomatobaconmayohambreadcheese" describing a sandwich
* use String.split to split up the sandwich by the word "bread" and return what's in the middle of the sandwich and ignores what's on the outside
* What if it's a fancy sandwich with multiple pieces of bread?
*/


//Your task pt 2:
/*Write a method that take in a string like "apples pineapples bread lettus tomato bacon mayo ham bread cheese" describing a sandwich
* use String.split to split up the sandwich at the spaces, " ", and return what's in the middle of the sandwich and ignores what's on the outside
* Again, what if it's a fancy sandwich with multiple pieces of bread?
*/



}
public static String sandwich_Pt1(String messedUpSandwich){
if(messedUpSandwich.indexOf("bread")<0||messedUpSandwich.indexOf("bread")==messedUpSandwich.lastIndexOf("bread"))
return "Not a sandwich!";
String orderedSandwich=messedUpSandwich.substring(messedUpSandwich.indexOf("bread"), messedUpSandwich.lastIndexOf("bread"));
String split[] =orderedSandwich.split("bread");
String answer="";
for(int i=1;i<split.length;i++)
answer=answer+split[i];
if (answer.trim().length()==0)
return "Not a sandwich!";
return answer;
}
public static String sandwich_Pt2(String messedUpSandwich){
if(messedUpSandwich.indexOf("bread")<0||messedUpSandwich.indexOf("bread")==messedUpSandwich.lastIndexOf("bread"))
return "Not a sandwich!";
String orderedSandwich=messedUpSandwich.substring(messedUpSandwich.indexOf("bread"), messedUpSandwich.lastIndexOf("bread"));
String split[] =orderedSandwich.split(" ");
String answer="";
for(int i=0;i<split.length;i++)
if(!split[i].equals("bread"))
answer=answer+split[i];
if (answer.trim().equals("breadbread")||answer.trim().equals("breadbreadbread"))
return "Not a sandwich!";
return answer;
}

}
@@ -0,0 +1,79 @@
import java.util.Arrays;

public class Sandwich_Pt1 {


public static void main(String[] args) {
System.out.println(Arrays.toString("I really really like really red apples".split("really")));
System.out.println(Arrays.toString("I like red apples".split(" ")));
//test for Part 1
System.out.println(sandwich_Pt1("breadmeatleetuceeadmayoketchuead"));
System.out.println(sandwich_Pt1("breadbread"));
System.out.println(sandwich_Pt1("bread"));
System.out.println(sandwich_Pt1("breadsomethingbreadmeatbread"));
System.out.println(sandwich_Pt1("cheesebreadsomethingbread"));
System.out.println(sandwich_Pt1("cheesebreadsomethingbreadotherstuff"));
System.out.println(sandwich_Pt1("breadbreadsomethingbread"));
System.out.println();
//test for Part 2
System.out.println(sandwich_Pt2("bread mayo bread mayo bread"));
System.out.println(sandwich_Pt2("something bread mayo bread mayo bread"));
System.out.println(sandwich_Pt2("bread bread bread"));
System.out.println(sandwich_Pt2("bread something bread bread"));
System.out.println(sandwich_Pt2("something bread bread bread"));
System.out.println(sandwich_Pt2("rottenstuff bread cheese bread bread"));
//String.split();
//It's a method that acts on a string, <StringName>.split(<String sp>);
//Where sp is the string where the string splits
//And it returns an array
// Example: "I like apples!".split(" ");
// it will split at spaces and return an array of ["I","like","apples!"]
// Example 2: "I really like really red apples"split("really")
// it will split at the word "really" and return an array of ["I "," like "," apples!"]

//play around with String.split! what happens if you "I reallyreally like apples".split("really") ?


//Your task:
/*Write a method that take in a string like "applespineapplesbreadlettustomatobaconmayohambreadcheese" describing a sandwich
* use String.split to split up the sandwich by the word "bread" and return what's in the middle of the sandwich and ignores what's on the outside
* What if it's a fancy sandwich with multiple pieces of bread?
*/


//Your task pt 2:
/*Write a method that take in a string like "apples pineapples bread lettus tomato bacon mayo ham bread cheese" describing a sandwich
* use String.split to split up the sandwich at the spaces, " ", and return what's in the middle of the sandwich and ignores what's on the outside
* Again, what if it's a fancy sandwich with multiple pieces of bread?
*/



}
public static String sandwich_Pt1(String messedUpSandwich){
if(messedUpSandwich.indexOf("bread")<0||messedUpSandwich.indexOf("bread")==messedUpSandwich.lastIndexOf("bread"))
return "Not a sandwich!";
String orderedSandwich=messedUpSandwich.substring(messedUpSandwich.indexOf("bread"), messedUpSandwich.lastIndexOf("bread"));
String split[] =orderedSandwich.split("bread");
String answer="";
for(int i=1;i<split.length;i++)
answer=answer+split[i];
if (answer.trim().length()==0)
return "Not a sandwich!";
return answer;
}
public static String sandwich_Pt2(String messedUpSandwich){
if(messedUpSandwich.indexOf("bread")<0||messedUpSandwich.indexOf("bread")==messedUpSandwich.lastIndexOf("bread"))
return "Not a sandwich!";
String orderedSandwich=messedUpSandwich.substring(messedUpSandwich.indexOf("bread"), messedUpSandwich.lastIndexOf("bread"));
String split[] =orderedSandwich.split(" ");
String answer="";
for(int i=0;i<split.length;i++)
if(!split[i].equals("bread"))
answer=answer+split[i];
if (answer.trim().length()==0)
return "Not a sandwich!";
return answer;
}

}
@@ -0,0 +1,78 @@
import java.util.Arrays;

public class Sandwich_Pt1 {


public static void main(String[] args) {
System.out.println(Arrays.toString("I really really like really red apples".split("really")));
System.out.println(Arrays.toString("I like red apples".split(" ")));
//test for Part 1
System.out.println(sandwich_Pt1("breadmeatleetuceeadmayoketchuead"));
System.out.println(sandwich_Pt1("breadbread"));
System.out.println(sandwich_Pt1("bread"));
System.out.println(sandwich_Pt1("breadsomethingbreadmeatbread"));
System.out.println(sandwich_Pt1("cheesebreadsomethingbread"));
System.out.println(sandwich_Pt1("cheesebreadsomethingbreadotherstuff"));
System.out.println(sandwich_Pt1("breadbreadsomethingbread"));
System.out.println();
//test for Part 2
System.out.println(sandwich_Pt2("bread mayo bread mayo bread"));
System.out.println(sandwich_Pt2("something bread mayo bread mayo bread"));
System.out.println(sandwich_Pt2("breadbreadbread"));
System.out.println(sandwich_Pt2("bread something bread bread"));
System.out.println(sandwich_Pt2("something bread bread bread"));
//String.split();
//It's a method that acts on a string, <StringName>.split(<String sp>);
//Where sp is the string where the string splits
//And it returns an array
// Example: "I like apples!".split(" ");
// it will split at spaces and return an array of ["I","like","apples!"]
// Example 2: "I really like really red apples"split("really")
// it will split at the word "really" and return an array of ["I "," like "," apples!"]

//play around with String.split! what happens if you "I reallyreally like apples".split("really") ?


//Your task:
/*Write a method that take in a string like "applespineapplesbreadlettustomatobaconmayohambreadcheese" describing a sandwich
* use String.split to split up the sandwich by the word "bread" and return what's in the middle of the sandwich and ignores what's on the outside
* What if it's a fancy sandwich with multiple pieces of bread?
*/


//Your task pt 2:
/*Write a method that take in a string like "apples pineapples bread lettus tomato bacon mayo ham bread cheese" describing a sandwich
* use String.split to split up the sandwich at the spaces, " ", and return what's in the middle of the sandwich and ignores what's on the outside
* Again, what if it's a fancy sandwich with multiple pieces of bread?
*/



}
public static String sandwich_Pt1(String messedUpSandwich){
if(messedUpSandwich.indexOf("bread")<0||messedUpSandwich.indexOf("bread")==messedUpSandwich.lastIndexOf("bread"))
return "Not a sandwich!";
String orderedSandwich=messedUpSandwich.substring(messedUpSandwich.indexOf("bread"), messedUpSandwich.lastIndexOf("bread"));
String split[] =orderedSandwich.split("bread");
String answer="";
for(int i=1;i<split.length;i++)
answer=answer+split[i];
if (answer.trim().length()==0)
return "Not a sandwich!";
return answer;
}
public static String sandwich_Pt2(String messedUpSandwich){
if(messedUpSandwich.indexOf("bread")<0||messedUpSandwich.indexOf("bread")==messedUpSandwich.lastIndexOf("bread"))
return "Not a sandwich!";
String orderedSandwich=messedUpSandwich.substring(messedUpSandwich.indexOf("bread"), messedUpSandwich.lastIndexOf("bread"));
String split[] =orderedSandwich.split(" ");
String answer="";
for(int i=0;i<split.length;i++)
if(!split[i].equals("bread"))
answer=answer+split[i];
if (answer.trim().equals("breadbread")||answer.trim().equals("breadbreadbread"))
return "Not a sandwich!";
return answer;
}

}
@@ -0,0 +1,53 @@
import java.util.Arrays;

public class Sandwich_Pt1 {


public static void main(String[] args) {
System.out.println(Arrays.toString("I really really like really red apples".split("really")));
System.out.println(Arrays.toString("I like red apples".split(" ")));
String test="breadmeatleetuceeadmayoketchuead";
String answer=sandwich(test);
System.out.println((answer));
//String.split();
//It's a method that acts on a string, <StringName>.split(<String sp>);
//Where sp is the string where the string splits
//And it returns an array
// Example: "I like apples!".split(" ");
// it will split at spaces and return an array of ["I","like","apples!"]
// Example 2: "I really like really red apples"split("really")
// it will split at the word "really" and return an array of ["I "," like "," apples!"]

//play around with String.split! what happens if you "I reallyreally like apples".split("really") ?


//Your task:
/*Write a method that take in a string like "applespineapplesbreadlettustomatobaconmayohambreadcheese" describing a sandwich
* use String.split to split up the sandwich by the word "bread" and return what's in the middle of the sandwich and ignores what's on the outside
* What if it's a fancy sandwich with multiple pieces of bread?
*/


//Your task pt 2:
/*Write a method that take in a string like "apples pineapples bread lettus tomato bacon mayo ham bread cheese" describing a sandwich
* use String.split to split up the sandwich at the spaces, " ", and return what's in the middle of the sandwich and ignores what's on the outside
* Again, what if it's a fancy sandwich with multiple pieces of bread?
*/



}
public static String sandwich(String messedUpSandwich){
if(messedUpSandwich.indexOf("bread")<0||messedUpSandwich.indexOf("bread")==messedUpSandwich.lastIndexOf("bread"))
return "Not a sandwich!";
String orderedSandwich=messedUpSandwich.substring(messedUpSandwich.indexOf("bread"), messedUpSandwich.lastIndexOf("bread"));
String split[] =orderedSandwich.split("bread");
String answer="";
for(int i=1;i<split.length;i++)
answer=answer+split[i];
if (answer.trim().length()==0)
return "Not a sandwich!";
return answer;
}

}
@@ -0,0 +1,76 @@
import java.util.Arrays;

public class Sandwich_Pt1 {


public static void main(String[] args) {
System.out.println(Arrays.toString("I really really like really red apples".split("really")));
System.out.println(Arrays.toString("I like red apples".split(" ")));
//test for Part 1
System.out.println(sandwich_Pt1("breadmeatleetuceeadmayoketchuead"));
System.out.println(sandwich_Pt1("breadbread"));
System.out.println(sandwich_Pt1("bread"));
System.out.println(sandwich_Pt1("breadsomethingbreadmeatbread"));
System.out.println(sandwich_Pt1("cheesebreadsomethingbread"));
System.out.println(sandwich_Pt1("cheesebreadsomethingbreadotherstuff"));
System.out.println(sandwich_Pt1("breadbreadsomethingbread"));
//test for Part 2
System.out.println(sandwich_Pt2("bread mayo bread mayo bread"));
System.out.println(sandwich_Pt2("something bread mayo bread mayo bread"));
System.out.println(sandwich_Pt2("breadbreadbread"));
System.out.println(sandwich_Pt2("bread something bread bread"));
//String.split();
//It's a method that acts on a string, <StringName>.split(<String sp>);
//Where sp is the string where the string splits
//And it returns an array
// Example: "I like apples!".split(" ");
// it will split at spaces and return an array of ["I","like","apples!"]
// Example 2: "I really like really red apples"split("really")
// it will split at the word "really" and return an array of ["I "," like "," apples!"]

//play around with String.split! what happens if you "I reallyreally like apples".split("really") ?


//Your task:
/*Write a method that take in a string like "applespineapplesbreadlettustomatobaconmayohambreadcheese" describing a sandwich
* use String.split to split up the sandwich by the word "bread" and return what's in the middle of the sandwich and ignores what's on the outside
* What if it's a fancy sandwich with multiple pieces of bread?
*/


//Your task pt 2:
/*Write a method that take in a string like "apples pineapples bread lettus tomato bacon mayo ham bread cheese" describing a sandwich
* use String.split to split up the sandwich at the spaces, " ", and return what's in the middle of the sandwich and ignores what's on the outside
* Again, what if it's a fancy sandwich with multiple pieces of bread?
*/



}
public static String sandwich_Pt1(String messedUpSandwich){
if(messedUpSandwich.indexOf("bread")<0||messedUpSandwich.indexOf("bread")==messedUpSandwich.lastIndexOf("bread"))
return "Not a sandwich!";
String orderedSandwich=messedUpSandwich.substring(messedUpSandwich.indexOf("bread"), messedUpSandwich.lastIndexOf("bread"));
String split[] =orderedSandwich.split("bread");
String answer="";
for(int i=1;i<split.length;i++)
answer=answer+split[i];
if (answer.trim().length()==0)
return "Not a sandwich!";
return answer;
}
public static String sandwich_Pt2(String messedUpSandwich){
if(messedUpSandwich.indexOf("bread")<0||messedUpSandwich.indexOf("bread")==messedUpSandwich.lastIndexOf("bread"))
return "Not a sandwich!";
String orderedSandwich=messedUpSandwich.substring(messedUpSandwich.indexOf("bread"), messedUpSandwich.lastIndexOf("bread"));
String split[] =orderedSandwich.split(" ");
String answer="";
for(int i=0;i<split.length;i++)
if(!split[i].equals("bread"))
answer=answer+split[i];
if (answer.trim().equals("breadbread")||answer.trim().equals("breadbreadbread"))
return "Not a sandwich!";
return answer;
}

}
@@ -0,0 +1,81 @@
import java.util.Arrays;

public class Sandwich_Pt1 {


public static void main(String[] args) {
System.out.println(Arrays.toString("I really really like really red apples".split("really")));
System.out.println(Arrays.toString("I like red apples".split(" ")));
//test for Part 1
System.out.println(sandwich_Pt1("breadmeatleetuceeadmayoketchuead"));
System.out.println(sandwich_Pt1("breadbread"));
System.out.println(sandwich_Pt1("bread"));
System.out.println(sandwich_Pt1("breadsomethingbreadmeatbreadmeat"));
System.out.println(sandwich_Pt1("cheesebreadsomethingbread"));
System.out.println(sandwich_Pt1("cheesebreadsomethingbreadotherstuff"));
System.out.println(sandwich_Pt1("breadbreadsomethingbread"));
System.out.println();
//test for Part 2
System.out.println(sandwich_Pt2("bread mayo bread mayo bread"));
System.out.println(sandwich_Pt2("something bread mayo bread mayo bread"));
System.out.println(sandwich_Pt2("bread bread bread"));
System.out.println(sandwich_Pt2("bread something bread bread"));
System.out.println(sandwich_Pt2("something bread bread bread"));
System.out.println(sandwich_Pt2("rottenstuff bread cheese bread bread meat"));
System.out.println(sandwich_Pt2("bread bread"));
System.out.println(sandwich_Pt2("bread"));
//String.split();
//It's a method that acts on a string, <StringName>.split(<String sp>);
//Where sp is the string where the string splits
//And it returns an array
// Example: "I like apples!".split(" ");
// it will split at spaces and return an array of ["I","like","apples!"]
// Example 2: "I really like really red apples"split("really")
// it will split at the word "really" and return an array of ["I "," like "," apples!"]

//play around with String.split! what happens if you "I reallyreally like apples".split("really") ?


//Your task:
/*Write a method that take in a string like "applespineapplesbreadlettustomatobaconmayohambreadcheese" describing a sandwich
* use String.split to split up the sandwich by the word "bread" and return what's in the middle of the sandwich and ignores what's on the outside
* What if it's a fancy sandwich with multiple pieces of bread?
*/


//Your task pt 2:
/*Write a method that take in a string like "apples pineapples bread lettus tomato bacon mayo ham bread cheese" describing a sandwich
* use String.split to split up the sandwich at the spaces, " ", and return what's in the middle of the sandwich and ignores what's on the outside
* Again, what if it's a fancy sandwich with multiple pieces of bread?
*/



}
public static String sandwich_Pt1(String messedUpSandwich){
if(messedUpSandwich.indexOf("bread")<0||messedUpSandwich.indexOf("bread")==messedUpSandwich.lastIndexOf("bread"))
return "Not a sandwich!";
String orderedSandwich=messedUpSandwich.substring(messedUpSandwich.indexOf("bread"), messedUpSandwich.lastIndexOf("bread"));
String split[] =orderedSandwich.split("bread");
String answer="";
for(int i=1;i<split.length;i++)
answer=answer+split[i];
if (answer.trim().length()==0)
return "Not a sandwich!";
return answer;
}
public static String sandwich_Pt2(String messedUpSandwich){
if(messedUpSandwich.indexOf("bread")<0||messedUpSandwich.indexOf("bread")==messedUpSandwich.lastIndexOf("bread"))
return "Not a sandwich!";
String orderedSandwich=messedUpSandwich.substring(messedUpSandwich.indexOf("bread"), messedUpSandwich.lastIndexOf("bread"));
String split[] =orderedSandwich.split(" ");
String answer="";
for(int i=0;i<split.length;i++)
if(!split[i].equals("bread"))
answer=answer+split[i];
if (answer.trim().length()==0)
return "Not a sandwich!";
return answer;
}

}
@@ -0,0 +1,52 @@
import java.util.Arrays;

public class Sandwich_Pt1 {


public static void main(String[] args) {
System.out.println(Arrays.toString("I really really like really red apples".split("really")));
String test="breadmeatleetuceeadmayoketchuead";
String answer=sandwich(test);
System.out.println((answer));
//String.split();
//It's a method that acts on a string, <StringName>.split(<String sp>);
//Where sp is the string where the string splits
//And it returns an array
// Example: "I like apples!".split(" ");
// it will split at spaces and return an array of ["I","like","apples!"]
// Example 2: "I really like really red apples"split("really")
// it will split at the word "really" and return an array of ["I "," like "," apples!"]

//play around with String.split! what happens if you "I reallyreally like apples".split("really") ?


//Your task:
/*Write a method that take in a string like "applespineapplesbreadlettustomatobaconmayohambreadcheese" describing a sandwich
* use String.split to split up the sandwich by the word "bread" and return what's in the middle of the sandwich and ignores what's on the outside
* What if it's a fancy sandwich with multiple pieces of bread?
*/


//Your task pt 2:
/*Write a method that take in a string like "apples pineapples bread lettus tomato bacon mayo ham bread cheese" describing a sandwich
* use String.split to split up the sandwich at the spaces, " ", and return what's in the middle of the sandwich and ignores what's on the outside
* Again, what if it's a fancy sandwich with multiple pieces of bread?
*/



}
public static String sandwich(String messedUpSandwich){
if(messedUpSandwich.indexOf("bread")<0||messedUpSandwich.indexOf("bread")==messedUpSandwich.lastIndexOf("bread"))
return "Not a sandwich!";
String orderedSandwich=messedUpSandwich.substring(messedUpSandwich.indexOf("bread"), messedUpSandwich.lastIndexOf("bread"));
String split[] =orderedSandwich.split("bread");
String answer="";
for(int i=1;i<split.length;i++)
answer=answer+split[i];
if (answer.trim().length()==0)
return "Not a sandwich!";
return answer;
}

}
@@ -0,0 +1,199 @@
public class Magpie4 {

//Get a default greeting and return a greeting
public String getGreeting() {
return "Hello, let's talk.";
}


/*
* 1) Copy and paste the code you wrote in Magpie 3 into the getResponse method. There is new code within the method
* but below where you will paste your code. Figure out what it does.
*
* 2) Copy and paste Part 3's getRandomResponse() code into the method below.
*
* 3) Alter the class as described in the handout.
*
*/


/**
* Gives a response to a user statement
* takes in user statement
* response based on the rules given
*/
public String getResponse(String statement) {
String response = "";
if (findKeyword(statement, "no", 0) >= 0) {
response = "Why so negative?";
}
else if (findKeyword(statement, "mother") >= 0
|| findKeyword(statement,"father") >= 0
|| findKeyword(statement,"sister") >= 0
|| findKeyword(statement,"brother") >= 0) {
response = "Tell me more about your family.";
}
else if (findKeyword(statement,"Dreyer")>=0){
response=("Ms. Dreyer is great at teaching!!!!");
}
else if (findKeyword(statement,"math")>=0
||findKeyword(statement,"physics")>=0){
response="Yes, I love the subject!";
}
else if (statement.trim().length()==0){
response="Say something please.";
}
else if(findKeyword(statement,"Nathan")>=0){
response="He is a cool person.";
}
else if(findKeyword(statement,"sport")>=0){
response="Tennis is a fun sport to play.";
}
// Responses which require transformations
else if (findKeyword(statement, "I want to", 0) >= 0) {
response = transformIWantToStatement(statement);
}

else {
// Look for a two word (you <something> me)
// pattern
int psn = findKeyword(statement, "you", 0);

if (psn >= 0 && findKeyword(statement, "me", psn) >= 0) {
response = transformYouMeStatement(statement);
} else {
response = getRandomResponse();
}
}
return response;
}
private int findKeyword(String statement, String goal, int startPos) {
String phrase = statement.trim();
// The only change to incorporate the startPos is in
// the line below
int psn = phrase.toLowerCase().indexOf(goal.toLowerCase(), startPos);

// Refinement--make sure the goal isn't part of a
// word
while (psn >= 0) {
// Find the string of length 1 before and after
// the word
String before = " ", after = " ";
if (psn > 0) {
before = phrase.substring(psn - 1, psn).toLowerCase();
}
if (psn + goal.length() < phrase.length()) {
after = phrase.substring(psn + goal.length(),
psn + goal.length() + 1).toLowerCase();
}

// If before and after aren't letters, we've
// found the word
if (before.equals(" ") && after.equals(" ")) {
return psn;
}

// The last position didn't work, so let's find
// the next, if there is one.
psn = phrase.indexOf(goal.toLowerCase(), psn + 1);

}

return -1;
}
private int findKeyword(String statement, String goal) {
return findKeyword(statement, goal, 0);
}


// Paste Part 3 code here. The method has new pieces that continue below and should flow from your previous code.


// Responses which require transformations

/**
* Take a statement with "I want to <something>." and transform it into
* "What would it mean to <something>?"
*
* @param statement
* the user statement, assumed to contain "I want to"
* @return the transformed statement
*/
private String transformIWantToStatement(String statement) {
// Remove the final period, if there is one
statement = statement.trim();
String lastChar = statement.substring(statement.length() - 1);
if (lastChar.equals(".")) {
statement = statement.substring(0, statement.length() - 1);
}
int psn = findKeyword(statement, "I want to", 0);
String restOfStatement = statement.substring(psn + 9).trim();
return "What would it mean to " + restOfStatement + "?";
}

/**
* Take a statement with "you <something> me" and transform it into
* "What makes you think that I <something> you?"
*
* @param statement
* the user statement, assumed to contain "you" followed by "me"
* @return the transformed statement
*/
private String transformYouMeStatement(String statement) {
// Remove the final period, if there is one
statement = statement.trim();
String lastChar = statement.substring(statement.length() - 1);
if (lastChar.equals(".")) {
statement = statement.substring(0, statement.length() - 1);
}

int psnOfYou = findKeyword(statement, "you", 0);
int psnOfMe = findKeyword(statement, "me", psnOfYou + 3);

String restOfStatement = statement.substring(psnOfYou + 3, psnOfMe)
.trim();
return "What makes you think that I " + restOfStatement + " you?";
}

/**
* Search for one word in phrase. The search is not case sensitive. This
* method will check that the given goal is not a substring of a longer
* string (so, for example, "I know" does not contain "no").
*
* parameter: statement
* the string to search
* parameter: goal
* the string to search for
* parameter: startPos
* the character of the string to begin the search at
* return the index of the first occurrence of goal in statement or -1 if
* it's not found
*/

/**
* Pick a default response to use if nothing else fits.
*
* @return a non-committal string
*/
private String getRandomResponse() {
final int NUMBER_OF_RESPONSES = 6;
double r = Math.random();
int whichResponse = (int) (r * NUMBER_OF_RESPONSES);
String response = "";

if (whichResponse == 0) {
response = "Interesting, tell me more.";
} else if (whichResponse == 1) {
response = "Hmmm.";
} else if (whichResponse == 2) {
response = "Do you really think so?";
} else if (whichResponse == 3) {
response = "You don't say.";
} else if (whichResponse == 4) {
response = "Where are you from?";
} else if (whichResponse == 5) {
response = "What are you saying?";
}
return response;
}
}
@@ -0,0 +1,74 @@
import java.util.Arrays;

public class Sandwich_Pt1 {


public static void main(String[] args) {
System.out.println(Arrays.toString("I really really like really red apples".split("really")));
System.out.println(Arrays.toString("I like red apples".split(" ")));
//test for Part 1
System.out.println(sandwich_Pt1("breadmeatleetuceeadmayoketchuead"));
System.out.println(sandwich_Pt1("breadbread"));
System.out.println(sandwich_Pt1("bread"));
System.out.println(sandwich_Pt1("breadsomethingbreadmeatbread"));
System.out.println(sandwich_Pt1("cheesebreadsomethingbread"));
System.out.println(sandwich_Pt1("cheesebreadsomethingbreadotherstuff"));
System.out.println(sandwich_Pt1("breadbreadsomethingbread"));
//test for Part 2
System.out.println(sandwich_Pt2("bread mayo bread mayo bread"));
System.out.println(sandwich_Pt2("something bread mayo bread mayo bread"));
System.out.println(sandwich_Pt2("breadbreadbread"));
//String.split();
//It's a method that acts on a string, <StringName>.split(<String sp>);
//Where sp is the string where the string splits
//And it returns an array
// Example: "I like apples!".split(" ");
// it will split at spaces and return an array of ["I","like","apples!"]
// Example 2: "I really like really red apples"split("really")
// it will split at the word "really" and return an array of ["I "," like "," apples!"]

//play around with String.split! what happens if you "I reallyreally like apples".split("really") ?


//Your task:
/*Write a method that take in a string like "applespineapplesbreadlettustomatobaconmayohambreadcheese" describing a sandwich
* use String.split to split up the sandwich by the word "bread" and return what's in the middle of the sandwich and ignores what's on the outside
* What if it's a fancy sandwich with multiple pieces of bread?
*/


//Your task pt 2:
/*Write a method that take in a string like "apples pineapples bread lettus tomato bacon mayo ham bread cheese" describing a sandwich
* use String.split to split up the sandwich at the spaces, " ", and return what's in the middle of the sandwich and ignores what's on the outside
* Again, what if it's a fancy sandwich with multiple pieces of bread?
*/



}
public static String sandwich_Pt1(String messedUpSandwich){
if(messedUpSandwich.indexOf("bread")<0||messedUpSandwich.indexOf("bread")==messedUpSandwich.lastIndexOf("bread"))
return "Not a sandwich!";
String orderedSandwich=messedUpSandwich.substring(messedUpSandwich.indexOf("bread"), messedUpSandwich.lastIndexOf("bread"));
String split[] =orderedSandwich.split("bread");
String answer="";
for(int i=1;i<split.length;i++)
answer=answer+split[i];
if (answer.trim().length()==0)
return "Not a sandwich!";
return answer;
}
public static String sandwich_Pt2(String messedUpSandwich){
if(messedUpSandwich.indexOf("bread")<0||messedUpSandwich.indexOf("bread")==messedUpSandwich.lastIndexOf("bread"))
return "Not a sandwich!";
String orderedSandwich=messedUpSandwich.substring(messedUpSandwich.indexOf("bread"), messedUpSandwich.lastIndexOf("bread"));
String split[] =orderedSandwich.split(" ");
String answer="";
for(int i=1;i<split.length;i++)
answer=answer+split[i];
if (answer.trim().equals("breadbread")||answer.trim().equals("breadbreadbread"))
return "Not a sandwich!";
return answer;
}

}
@@ -0,0 +1,58 @@
import java.util.Arrays;

public class Sandwich_Pt1 {


public static void main(String[] args) {
System.out.println(Arrays.toString("I really really like really red apples".split("really")));
System.out.println(Arrays.toString("I like red apples".split(" ")));
String test="breadmeatleetuceeadmayoketchuead";
System.out.println(sandwich(test));
System.out.println(sandwich("breadbread"));
System.out.println(sandwich("bread"));
System.out.println(sandwich("breadsomethingbreadmeatbread"));
System.out.println(sandwich("cheesebreadsomethingbread"));
System.out.println(sandwich("cheesebreadsomethingbreadotherstuff"));
System.out.println("breadbreadsomethingbread");
//String.split();
//It's a method that acts on a string, <StringName>.split(<String sp>);
//Where sp is the string where the string splits
//And it returns an array
// Example: "I like apples!".split(" ");
// it will split at spaces and return an array of ["I","like","apples!"]
// Example 2: "I really like really red apples"split("really")
// it will split at the word "really" and return an array of ["I "," like "," apples!"]

//play around with String.split! what happens if you "I reallyreally like apples".split("really") ?


//Your task:
/*Write a method that take in a string like "applespineapplesbreadlettustomatobaconmayohambreadcheese" describing a sandwich
* use String.split to split up the sandwich by the word "bread" and return what's in the middle of the sandwich and ignores what's on the outside
* What if it's a fancy sandwich with multiple pieces of bread?
*/


//Your task pt 2:
/*Write a method that take in a string like "apples pineapples bread lettus tomato bacon mayo ham bread cheese" describing a sandwich
* use String.split to split up the sandwich at the spaces, " ", and return what's in the middle of the sandwich and ignores what's on the outside
* Again, what if it's a fancy sandwich with multiple pieces of bread?
*/



}
public static String sandwich(String messedUpSandwich){
if(messedUpSandwich.indexOf("bread")<0||messedUpSandwich.indexOf("bread")==messedUpSandwich.lastIndexOf("bread"))
return "Not a sandwich!";
String orderedSandwich=messedUpSandwich.substring(messedUpSandwich.indexOf("bread"), messedUpSandwich.lastIndexOf("bread"));
String split[] =orderedSandwich.split("bread");
String answer="";
for(int i=1;i<split.length;i++)
answer=answer+split[i];
if (answer.trim().length()==0)
return "Not a sandwich!";
return answer;
}

}
@@ -0,0 +1,50 @@

public class Sandwich_Pt1 {


public static void main(String[] args) {
String test="breadmeatleetuceeadmayoketchuead";
String answer=sandwich(test);
System.out.println((answer));
//String.split();
//It's a method that acts on a string, <StringName>.split(<String sp>);
//Where sp is the string where the string splits
//And it returns an array
// Example: "I like apples!".split(" ");
// it will split at spaces and return an array of ["I","like","apples!"]
// Example 2: "I really like really red apples"split("really")
// it will split at the word "really" and return an array of ["I "," like "," apples!"]

//play around with String.split! what happens if you "I reallyreally like apples".split("really") ?


//Your task:
/*Write a method that take in a string like "applespineapplesbreadlettustomatobaconmayohambreadcheese" describing a sandwich
* use String.split to split up the sandwich by the word "bread" and return what's in the middle of the sandwich and ignores what's on the outside
* What if it's a fancy sandwich with multiple pieces of bread?
*/


//Your task pt 2:
/*Write a method that take in a string like "apples pineapples bread lettus tomato bacon mayo ham bread cheese" describing a sandwich
* use String.split to split up the sandwich at the spaces, " ", and return what's in the middle of the sandwich and ignores what's on the outside
* Again, what if it's a fancy sandwich with multiple pieces of bread?
*/



}
public static String sandwich(String messedUpSandwich){
if(messedUpSandwich.indexOf("bread")<0||messedUpSandwich.indexOf("bread")==messedUpSandwich.lastIndexOf("bread"))
return "Not a sandwich!";
String orderedSandwich=messedUpSandwich.substring(messedUpSandwich.indexOf("bread"), messedUpSandwich.lastIndexOf("bread"));
String split[] =orderedSandwich.split("bread");
String answer="";
for(int i=1;i<split.length;i++)
answer=answer+split[i];
if (answer.trim().length()==0)
return "Not a sandwich!";
return answer;
}

}
@@ -0,0 +1,72 @@
import java.util.Arrays;

public class Sandwich_Pt1 {


public static void main(String[] args) {
System.out.println(Arrays.toString("I really really like really red apples".split("really")));
System.out.println(Arrays.toString("I like red apples".split(" ")));
//test for Part 1
System.out.println(sandwich_Pt1("breadmeatleetuceeadmayoketchuead"));
System.out.println(sandwich_Pt1("breadbread"));
System.out.println(sandwich_Pt1("bread"));
System.out.println(sandwich_Pt1("breadsomethingbreadmeatbread"));
System.out.println(sandwich_Pt1("cheesebreadsomethingbread"));
System.out.println(sandwich_Pt1("cheesebreadsomethingbreadotherstuff"));
System.out.println(sandwich_Pt1("breadbreadsomethingbread"));
//test for Part 2
System.out.println(sandwich_Pt2("bread mayo bread mayo bread"));
//String.split();
//It's a method that acts on a string, <StringName>.split(<String sp>);
//Where sp is the string where the string splits
//And it returns an array
// Example: "I like apples!".split(" ");
// it will split at spaces and return an array of ["I","like","apples!"]
// Example 2: "I really like really red apples"split("really")
// it will split at the word "really" and return an array of ["I "," like "," apples!"]

//play around with String.split! what happens if you "I reallyreally like apples".split("really") ?


//Your task:
/*Write a method that take in a string like "applespineapplesbreadlettustomatobaconmayohambreadcheese" describing a sandwich
* use String.split to split up the sandwich by the word "bread" and return what's in the middle of the sandwich and ignores what's on the outside
* What if it's a fancy sandwich with multiple pieces of bread?
*/


//Your task pt 2:
/*Write a method that take in a string like "apples pineapples bread lettus tomato bacon mayo ham bread cheese" describing a sandwich
* use String.split to split up the sandwich at the spaces, " ", and return what's in the middle of the sandwich and ignores what's on the outside
* Again, what if it's a fancy sandwich with multiple pieces of bread?
*/



}
public static String sandwich_Pt1(String messedUpSandwich){
if(messedUpSandwich.indexOf("bread")<0||messedUpSandwich.indexOf("bread")==messedUpSandwich.lastIndexOf("bread"))
return "Not a sandwich!";
String orderedSandwich=messedUpSandwich.substring(messedUpSandwich.indexOf("bread"), messedUpSandwich.lastIndexOf("bread"));
String split[] =orderedSandwich.split("bread");
String answer="";
for(int i=1;i<split.length;i++)
answer=answer+split[i];
if (answer.trim().length()==0)
return "Not a sandwich!";
return answer;
}
public static String sandwich_Pt2(String messedUpSandwich){
if(messedUpSandwich.indexOf("bread")<0||messedUpSandwich.indexOf("bread")==messedUpSandwich.lastIndexOf("bread"))
return "Not a sandwich!";
String orderedSandwich=messedUpSandwich.substring(messedUpSandwich.indexOf(" "), messedUpSandwich.lastIndexOf("bread"));
String split[] =orderedSandwich.split("bread");
String answer="";
for(int i=2;i<split.length;i++)
answer=answer+split[i];
if (answer.trim().equals("breadbread")||answer.trim().equals("breadbreadbread"))
return "Not a sandwich!";
return answer;
}

}
@@ -0,0 +1,76 @@
import java.util.Arrays;

public class Sandwich_Pt1 {


public static void main(String[] args) {
System.out.println(Arrays.toString("I really really like really red apples".split("really")));
System.out.println(Arrays.toString("I like red apples".split(" ")));
//test for Part 1
System.out.println(sandwich_Pt1("breadmeatleetuceeadmayoketchuead"));
System.out.println(sandwich_Pt1("breadbread"));
System.out.println(sandwich_Pt1("bread"));
System.out.println(sandwich_Pt1("breadsomethingbreadmeatbread"));
System.out.println(sandwich_Pt1("cheesebreadsomethingbread"));
System.out.println(sandwich_Pt1("cheesebreadsomethingbreadotherstuff"));
System.out.println(sandwich_Pt1("breadbreadsomethingbread"));
//test for Part 2
System.out.println(sandwich_Pt2("bread mayo bread mayo bread"));
System.out.println(sandwich_Pt2("something bread mayo bread mayo bread"));
System.out.println(sandwich_Pt2("breadbreadbread"));
System.out.println(sandwich_Pt2("breadsomethingbreadbread"));
//String.split();
//It's a method that acts on a string, <StringName>.split(<String sp>);
//Where sp is the string where the string splits
//And it returns an array
// Example: "I like apples!".split(" ");
// it will split at spaces and return an array of ["I","like","apples!"]
// Example 2: "I really like really red apples"split("really")
// it will split at the word "really" and return an array of ["I "," like "," apples!"]

//play around with String.split! what happens if you "I reallyreally like apples".split("really") ?


//Your task:
/*Write a method that take in a string like "applespineapplesbreadlettustomatobaconmayohambreadcheese" describing a sandwich
* use String.split to split up the sandwich by the word "bread" and return what's in the middle of the sandwich and ignores what's on the outside
* What if it's a fancy sandwich with multiple pieces of bread?
*/


//Your task pt 2:
/*Write a method that take in a string like "apples pineapples bread lettus tomato bacon mayo ham bread cheese" describing a sandwich
* use String.split to split up the sandwich at the spaces, " ", and return what's in the middle of the sandwich and ignores what's on the outside
* Again, what if it's a fancy sandwich with multiple pieces of bread?
*/



}
public static String sandwich_Pt1(String messedUpSandwich){
if(messedUpSandwich.indexOf("bread")<0||messedUpSandwich.indexOf("bread")==messedUpSandwich.lastIndexOf("bread"))
return "Not a sandwich!";
String orderedSandwich=messedUpSandwich.substring(messedUpSandwich.indexOf("bread"), messedUpSandwich.lastIndexOf("bread"));
String split[] =orderedSandwich.split("bread");
String answer="";
for(int i=1;i<split.length;i++)
answer=answer+split[i];
if (answer.trim().length()==0)
return "Not a sandwich!";
return answer;
}
public static String sandwich_Pt2(String messedUpSandwich){
if(messedUpSandwich.indexOf("bread")<0||messedUpSandwich.indexOf("bread")==messedUpSandwich.lastIndexOf("bread"))
return "Not a sandwich!";
String orderedSandwich=messedUpSandwich.substring(messedUpSandwich.indexOf("bread"), messedUpSandwich.lastIndexOf("bread"));
String split[] =orderedSandwich.split(" ");
String answer="";
for(int i=0;i<split.length;i++)
if(!split[i].equals("bread"))
answer=answer+split[i];
if (answer.trim().equals("breadbread")||answer.trim().equals("breadbreadbread"))
return "Not a sandwich!";
return answer;
}

}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -2,8 +2,8 @@
<launchHistory>
<launchGroup id="org.eclipse.debug.ui.launchGroup.debug">
<mruHistory>
<launch memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;launchConfiguration local=&quot;true&quot; path=&quot;DoMath&quot;/&gt;&#13;&#10;"/>
<launch memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;launchConfiguration local=&quot;true&quot; path=&quot;Sandwich_Pt1&quot;/&gt;&#13;&#10;"/>
<launch memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;launchConfiguration local=&quot;true&quot; path=&quot;DoMath&quot;/&gt;&#13;&#10;"/>
<launch memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;launchConfiguration local=&quot;true&quot; path=&quot;MagpieRunner4&quot;/&gt;&#13;&#10;"/>
<launch memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;launchConfiguration local=&quot;true&quot; path=&quot;HourglassNathan&quot;/&gt;&#13;&#10;"/>
<launch memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;launchConfiguration local=&quot;true&quot; path=&quot;ProcessingNumbers&quot;/&gt;&#13;&#10;"/>
@@ -21,8 +21,8 @@
</launchGroup>
<launchGroup id="org.eclipse.debug.ui.launchGroup.run">
<mruHistory>
<launch memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;launchConfiguration local=&quot;true&quot; path=&quot;DoMath&quot;/&gt;&#13;&#10;"/>
<launch memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;launchConfiguration local=&quot;true&quot; path=&quot;Sandwich_Pt1&quot;/&gt;&#13;&#10;"/>
<launch memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;launchConfiguration local=&quot;true&quot; path=&quot;DoMath&quot;/&gt;&#13;&#10;"/>
<launch memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;launchConfiguration local=&quot;true&quot; path=&quot;MagpieRunner4&quot;/&gt;&#13;&#10;"/>
<launch memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;launchConfiguration local=&quot;true&quot; path=&quot;HourglassNathan&quot;/&gt;&#13;&#10;"/>
<launch memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;launchConfiguration local=&quot;true&quot; path=&quot;ProcessingNumbers&quot;/&gt;&#13;&#10;"/>

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.

This file was deleted.

This file was deleted.

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
���� fingerprintactionbugIdbugUrlmessage needinfos

Large diffs are not rendered by default.

@@ -0,0 +1 @@
NRM�j|x|h]jao|||||vphypk|b|||s|nr|g||\md|lpii|chjbrhl|befhg||||th||p||lgcyxji|sk|||yntmd|[|lrippy|pv|q|r|hyn|||xildy|xocq|uyjjxtmpc|kjhhx|upuuuuuuuuuuuuuu|tiu|y||ntpr|l|t|u|x||tw||t|mmo||r|s|vv||||p|||t|x||t||p|nqaxa||ldvddvh|`lpqqs|tgte||tqxtr||rx|||uq||u|lyudc\|k\[|dj\uqw|su||hlotxwxvtx||r||t|v|w|wvv||v|||||tf\|chtsqg|gnvxxwvx|pttttyy|ramaaaamxlylqioppnqs|s|pjpolpp||dnpppppojpeevnpiru|w|cuttjy|rrrw||t||i|lmfi||i|geir|yl||||||u|ig||lkvke||||||ml|||elrxm|x||n|y||||||||bk||j||vjh|mv||r|w|h|w|h|pw|y||m`y|lp|px|jfu|v||yv||xyux||n||y||x|||c|h||ylpl|n|u|h|||guxcchy|u|s||||ho||v|v|te||||s||h|xxdsvu|u|o|u||||oi||||qcd|idnv||q`t||x|n||lqf|j|k||g||||t|rkqw|||||gp|tu|||t|||h|y|j||c|||a|||||||h|y|v|u|hu|y|||s|||m|mpy|||x|||cfxy||||||||||kx|||nl||k||v||||||||||||||pkwxyw||||||w||p|||||w|||qu|my||||htq|||l||mnx||||lny|||v|n||||||||xyrx|||l||u|||l|||||y|y|p|||||||||ppv|u||||p|u|rt|l||t|x||||||y|kx|||ony||r|qr|vwy|||||x||t||ryxy|||q|||qf|t||x|vxhyp|y||hl|||fu|k|vrk|yfh||i|||v|px|o||||xnin|p|||p|q|||x|||rl|q||||||luv|twp|yxtw|||nxm|||v|x|w|h|v|vv|||x|toxp||y|||||y||m||y|||q||pr|yw|r||wd|||||||||||q||n||||||||j||n||y||px|r|||l|||||||||kp|puv||v|||||nvgir||||i|ftrt||axxldp|||g|y|xc|j|||w|lxopf||||||yfv|||xi|||||cf||r||||tuerymxp|wy||||u|n|l|tyyxxvxsr|x||||nwy|p||||||t||||u|||y|||o|y|rqyl|||||rm|||w|tw|xx||t||y||vx|vt|||||ham||pq|o|x|mx||u|||yn|n|||y|xxxsay|||rjh|jtnowyx|qsx|||yt||qryv|ty|c|||||s||ty|os||st||e||`|||cxw|lr||r|x|m|cup|lxy|tqu|x|||||v|||||u||||t||qwpyyw||uyv||t|x|ytexy|k|sxsxnyyt|yy|yn||w|j||ufyxy||||yr||||xk||||up|mxyyvwyv|yxy||y|||y||xxxxyx|xxx||gxuYpxy|wtqu|pymvxom||yy||rm||whvqktvyxt|l|xn||oyylx||v||xtix||yvtyyv|x||ty|xxv|rt`|qkert||yy||wx|w||wuxyy|yyvvyyoq||||rtsy|noqur||yy|t|rvyuuu||y|||yrsuruymxy|tuytt|xtx||x||w|||x|vtywvyy||xr|||imt||xt|vx||wuyy|yx|v|u|x|||yn|xuh|y||||||x|||y|yvyx||x|y|xr||u||mf|||afordicdbefdhfddafoplm`e|qatmoklihhrgcqfkghnhmlcghkq`ikhffhlioefjpkkg`i|hablaliinbihnl|fgiqgp|lkhktsih|itioqjoqeki|ekexj|vyhlkimpd|mqpb|||iihigmmdjwxtm|lh|||l||kvm||j|kkagng||gm|jgpcc|bvgsu||`x|n||m||f||ixoyxty|m|vx|httnvlf|||ll|jjm|lnvp|umnxosmx|||||rtx|s|x||jjxy||||ps|n|v|s|uojjhgj|esiu|lg|txuqyyxxv||rjy|uukym|||||||t|uvstxp||sw|ww|yxt||ov|wqdlsmxqrvx|ywtl||y|xx||y|hyyyyyr|||q|yyy|w|y|yy|||xyy|x|||ytx|y|y|x|y|y|||||q|r||xjj||i||||lcl|j|hdsumhbe||jwy|n|utikl||^gutamxm|jioou|jp|mkpqi|g|p|sfj|cxehneiikn|inylfympponrooxtri||ghmkgh|e|n\t||pnhh|hmxbs|njhq`|imrgu|pkqy|yvnptixsxp|jtv||oudpg|urjp||iqkdsdd|w||pnjtlj|u|jp|mmmxjihkh|q|bd|f|n|l|kafphohnl|`pfqkftij||nhipmlkf|opn||sp||uhigk||unnpso|wrsssjfdqm||qh|n|||||vvbv|||p|myppn|ed`wjmp_hhgomxscfcifgwqhjjlejqljhkgtmknmhijnekglqlmlnrnmpg|krwqqop|wuymtyuqlo|xxxxupxmpttu|srqrgvpxqmyvweprqmtkmfnoomgtphutwtmpmssipoljqnxrtrvpaqvvt|ympklppxpptksyu|tvnusmkmtxrtsoppxup|vsbiqvqqtvptruwuwkpswy|yuxuqrvurnusutqqrx||struspurpxwrutrvuvnl|qxqetx|w|qosvutustuilxwtvsrlvs|xrwivspspry||ptrroxkpnnxqrtovwrt`nrttwtrr|sytvvsrtutvxpqtpxvurrxx|yilxqqtsupvqmvjtusrqruwoyotxq|qoyplittxxsn|rquv|seutsrswtlspv|ytxxxvt||yhhut|xxtuvrtv|yvvy|y|\u||yvx|qtuwvx|xvqvvtrrv|xrutyxyyvvsvuur|||y|tr|xxxxwyoq|kuyyxxtxyv|qprxwxxxx||mnqsxqvuty|||xtxwwutvrtvxvwqouyxvuxsrx|wtttxttxwxmxyxx|tyy|vxxyyyxyx||uyxvpxytstytsqtvuxyxyvv||||e|yynrx|x|u|yyxtttu||l|yyyyxxxw|vty|qxxu||yyxu|||rt|vywyv|wxvyyvxxx||xrxv|uswvyysq|||uxwuyyyy||xxyyyy|x|||yyp|||yuvuus|tyy|x|xix|xyxxxyyxxvwo|wywuyyt||niw|y|||||u|||ywy|yyxgxx|y||yyy|kqt||up||||u|sq||yy|xmmmp|qyx|yy|yy||nn|||nmqqxy|yy|vv|vuvxyxyxxxyh|q|vy|yvy||xx|x||kmy||xxyxtyy|xxxww|x|||xyx|vx|x|y|x|||xpxx|wx||||xs||lvxxyvxyw|yy|x|q|ty|v|x|wv|yxr|y|vxwxy|r|xhyx|||x|vwxw||||yyyy||||||||||t|xy||||wypy||ww|xx||xxh||fjqgeng||abpnxiu||xpyx|y||||yy|||||xwuvu|xvvuwyy|v|||||y|yy||||x||rl|||xwuyyy|yyrlq||yyy||wur||x|x||yyx||uuwxt||u|xy|ttyy||||xyty|wr||||pyurxw|vy|||||uyvy|w|||pyyy||yxyyyyx|wx||xyx|||||q|xyx|||xyxx|y||y||yfijec`d|klobaitj|xf|k||f|||i||md||ehk^|||m|iojcmyhl|hkoesvq||m|`pf||h||rbyn|d`srwo`mg|i|||||qjke|cgohmpdtiej|fwqp|_igr|xnoqknlejf|qidaet|shfvkqhrhhtgrvhnkddi|hilnf|hmlo|n|i|vnhiwh|sihmtjgmkg|gphmiijdeoowdhei|qhhuegnnwixikn|gdp|||mn|tgkldmf|tk|iyuxi|s|qthrfosmtmumvdphoitvm|jxmr||xtsyfmml||lq|wu|pp|fanqisfnnk|tkkp|^pm`feqqx|ntp|mhwliqgdhfnkrqfchjgeigiag|rxjhftf|it|a||ehjiwehsukinmhvsgjx||xtvxuou||svvynrglcfxhs|iuty|yhriuuam|hrlqidm||ehhou|x|jpnkqdh||xrymwa|v|ho`tydhqiuxd|uihd|pi||yv||||h|nq|||j|p|||vj|||tbpnwxt|sbl|tt|p|||||h||w|t||n|m|hh|u|jy||qsdl|vxu||is`p|p`i|oovusq||n|p|rphwolow||tr|rml|||qhox|nllpeyqp|vt|tptjs|pp`|tx|m|t||lo|tp||ruotrfw|rurrnxrywp|ro||||t|w||uql|tov|y||qho|f||lv||i||xwm|t|mjlrrpmluuptngq|ni|q|u||glsssjmp||q||y|||||vp|xqxy||y|||xtyexyxl|ewsxtjtfux|vy|tm||p|y||t|bukhwqxuuqvlvxv|y|xhmdquf|mvp|st||uwq|wxyxp|yyxryuyxujxx|llyx|ut|bx||y||qlhw||jxttu||t||wfy|t|||wtqivtprwoyx|ptqxxxxtypr|tywy|pypyyq|ywx|vxx|||wyx||yy||||xxx||||xtxi|r||opvppm|||y|l|strr|||wwx||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,7 +1,7 @@
{
"version": "v1",
"title": "Eclipse Automated Error Reporting",
"timestamp": 1477262035088,
"timestamp": 1478060715047,
"ttl": 10080,
"helpUrl": "https://dev.eclipse.org/recommenders/community/aeri/v2/help/",
"feedbackUrl": "http://ctrlflow.com/automated-error-reporting",
@@ -62,5 +62,5 @@
"org.eclipse.pde.core::The current target platform contains errors*",
"org.eclipse.ui::Conflicting handlers for*"
],
"problemsZipLastDownloadTimestamp": 1477262342638
"problemsZipLastDownloadTimestamp": 1478061023455
}
Binary file not shown.
Binary file not shown.
@@ -6,12 +6,12 @@ INDEX VERSION 1.129+C:\Users\Vincent\Desktop\Vincent_APCS_Fall2016\.metadata\.pl
2855899100.index
2637943071.index
2800558102.index
414978335.index
468246969.index
1644702904.index
781808.index
4184201189.index
468246969.index
3217711519.index
4184201189.index
414978335.index
2133282975.index
2019903893.index
1273266910.index
@@ -26,3 +26,5 @@
2016-10-27 09:14:19,304 [Worker-3] INFO c.g.t.t.d.PublishedGradleVersions - Gradle version information cache is up-to-date. Trying to read.
2016-10-28 09:27:01,608 [Worker-3] INFO c.g.t.t.d.PublishedGradleVersions - Gradle version information cache is out-of-date. Trying to update.
2016-10-29 00:27:28,119 [Worker-5] INFO c.g.t.t.d.PublishedGradleVersions - Gradle version information cache is out-of-date. Trying to update.
2016-11-01 21:25:11,277 [Worker-0] INFO c.g.t.t.d.PublishedGradleVersions - Gradle version information cache is out-of-date. Trying to update.
2016-11-01 22:27:11,376 [Worker-0] INFO c.g.t.t.d.PublishedGradleVersions - Gradle version information cache is up-to-date. Trying to read.
@@ -1,3 +1,3 @@
#Sat Oct 29 00:26:47 PDT 2016
#Tue Nov 01 22:26:37 PDT 2016
org.eclipse.core.runtime=2
org.eclipse.platform=4.6.0.v20160606-1100
@@ -1 +1 @@
{}
[[{"location":"C:\\Program Files\\Java\\jre1.8.0_101","type":"JRE","hints":{"EXECUTION_ENVIRONMENT":"JavaSE-1.8"}},"jre:jre:1.8.0"]]
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,11 +1,30 @@
import java.util.Arrays;

public class Sandwich_Pt1 {


public static void main(String[] args) {
String test="breadmeatleetuceeadmayoketchuead";
String answer=sandwich(test);
System.out.println((answer));
System.out.println(Arrays.toString("I really really like really red apples".split("really")));
System.out.println(Arrays.toString("I like red apples".split(" ")));
//test for Part 1
System.out.println(sandwich_Pt1("breadmeatleetuceeadmayoketchuead"));
System.out.println(sandwich_Pt1("breadbread"));
System.out.println(sandwich_Pt1("bread"));
System.out.println(sandwich_Pt1("breadsomethingbreadmeatbreadmeat"));
System.out.println(sandwich_Pt1("cheesebreadsomethingbread"));
System.out.println(sandwich_Pt1("cheesebreadsomethingbreadotherstuff"));
System.out.println(sandwich_Pt1("breadbreadsomethingbread"));
System.out.println();
//test for Part 2
System.out.println(sandwich_Pt2("bread mayo bread mayo bread"));
System.out.println(sandwich_Pt2("something bread mayo bread mayo bread"));
System.out.println(sandwich_Pt2("bread bread bread"));
System.out.println(sandwich_Pt2("bread something bread bread"));
System.out.println(sandwich_Pt2("bread something bread meat cheese bread"));
System.out.println(sandwich_Pt2("something bread bread bread"));
System.out.println(sandwich_Pt2("rottenstuff bread cheese bread bread meat"));
System.out.println(sandwich_Pt2("bread bread"));
System.out.println(sandwich_Pt2("bread"));
//String.split();
//It's a method that acts on a string, <StringName>.split(<String sp>);
//Where sp is the string where the string splits
@@ -34,7 +53,7 @@ public static void main(String[] args) {


}
public static String sandwich(String messedUpSandwich){
public static String sandwich_Pt1(String messedUpSandwich){
if(messedUpSandwich.indexOf("bread")<0||messedUpSandwich.indexOf("bread")==messedUpSandwich.lastIndexOf("bread"))
return "Not a sandwich!";
String orderedSandwich=messedUpSandwich.substring(messedUpSandwich.indexOf("bread"), messedUpSandwich.lastIndexOf("bread"));
@@ -46,5 +65,18 @@ public static String sandwich(String messedUpSandwich){
return "Not a sandwich!";
return answer;
}
public static String sandwich_Pt2(String messedUpSandwich){
if(messedUpSandwich.indexOf("bread")<0||messedUpSandwich.indexOf("bread")==messedUpSandwich.lastIndexOf("bread"))
return "Not a sandwich!";
String orderedSandwich=messedUpSandwich.substring(messedUpSandwich.indexOf("bread"), messedUpSandwich.lastIndexOf("bread"));
String split[] =orderedSandwich.split(" ");
String answer="";
for(int i=0;i<split.length;i++)
if(!split[i].equals("bread"))
answer=answer+split[i];
if (answer.trim().length()==0)
return "Not a sandwich!";
return answer;
}

}
BIN +135 Bytes (100%) Magpie4/bin/Magpie4.class
Binary file not shown.
@@ -34,7 +34,13 @@ else if (findKeyword(statement, "mother") >= 0
response = "Tell me more about your family.";
}
else if (findKeyword(statement,"Dreyer")>=0){
response=("Ms. Dreyer is great at teaching!!!!");
response=("Ms. Dreyer is great at APCS!!!!");
}
else if (findKeyword(statement,"seniors")>=0){
response=("Being a senior is hard.");
}
else if (findKeyword(statement,"stupid")>=0){
response=("Stupid is a bad word.");
}
else if (findKeyword(statement,"math")>=0
||findKeyword(statement,"physics")>=0){