Barron's online test, Test #1 FRQ#1. Write your responses for part a and part b by 11:59pm, 3/23/2019.
To see this working, head to your live site.
Search
sfolax6776
Mar 23, 2019
Test Prep Daily Practice - Week 1 Day 1, Saturday, 3/23
Test Prep Daily Practice - Week 1 Day 1, Saturday, 3/23
8 comments
0
public void printNotes(){
for(int i=0;i<noteList.size();i++){
System.out.println(((i+1)+". ")+noteList.get(i));
}
}
public void removeNotes(String str){
int totalChar = 0;
for(int i=0;i<noteList.size();i++){
for(j=0;j<noteList.get(i).length()-str.length();j++){
if(noteList.get(i).substring(j,j+str.length()).compareTo(str)==0){
noteList.remove(i);
}
}
}
}
You nailed both!
a.
public void printNotes(){
Note n=new Note();
for(int i=0;i<n.size();i++){
System.out.println((i+1)+". "n.getNote(i));
}
}
This is Jerry
Nice try Jerry. You started a new Note object, as a matter of fact, you only need to print out the noteList.
b.
public void removeNotes(String str){
Note n=new Notes();
for(int i=0;i<n.size();i++){
for(int j=0;j<n.get(i).length;j++){
for(int r=0;r<n.get(i).length;r++){
if(n.get(i).substring(j,r)==str){
n.remove(i);
}
}
}
}
}
Nice flow. Again, the instance variable noteList has the list of notes to remove from.
There is a method named "indexOf(String s)", it can be used to see if a string contains another string.
https://www.tutorialspoint.com/java/java_string_indexof.htm