Instructions: Answer the following questions one at a time. After answering each question, check your answer (by clicking on the check-mark icon if it is available) before proceeding to the next question.
Getting Ready: Before going any further, you should:
.java
Files: In most IDEs, .java
files
(i.e., source files) can just be copied into the project.
.class
and .jar
Files:
In some IDEs it is easier to use .class
files and in others it is easier to use a .jar
file
that contains the .class
files. Hence, you have been
provided with both.
See the course "Help" page on your IDE for more information.
Resources: In some IDEs, resources (e.g., images, data files) need to be in a special directory whereas in others they need to be in the working directory. See the course "Help" page on your IDE for more information.
For a variety of reasons (that you either already understand because we have covered parameterized classes/interfaces or will understand later in the semester when we do), you will get a warning when you compile some of the classes that says something like:
... uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details.
You can and should just ignore this warning.
Extreminator.java
and ExtreminatorDriver.java
files.
ExtreminatorDriver
. What
output was generated?
findInf()
method to the following:
// Refinement -- start at the next index if (values[startIndex] < soFar) { soFar = values[startIndex]; } soFar = findInf(values, startIndex, soFar);
findInf()
method to the following:
// Refinement -- start at the next index if (values[startIndex] < soFar) { soFar = values[startIndex]; soFar = findInf(values, startIndex+1, soFar); }
findInf()
method to the following:
// Refinement -- start at the next index if (values[startIndex] < soFar) { soFar = values[startIndex]; soFar = findInf(values, startIndex, soFar); }
WordGames
. (This will be a utility
class.)
occurrences()
to the WordGames
class. It must return an int
and be passed two String
parameters named
pattern
and source
.
String
(called the pattern
)
occurs in another String
(called the source
).
source
objects is this problem really easy? (Hint: Think
about properties of the source
objects, not the
specific values.)
occurrences()
method to handle this case. (Note: Your code may not use any methods
in the String
class other than the
length()
method.)
What code did you add?
occurrences()
method to handle your
refinement process. Remember, you must both move the parameter
closer to the base case and move the answer closer to the correct
answer. (Note: Your code may not use any methods in
the String
class other than the
substring()
and startsWith()
methods.)
What code did you add?
occurrences()
method
using the following cases:
n intelligent i intelligent p hippopotomonstrosesquippedaliophobia ed educated meow homeowner
Extreminator.java
into the
working directory (i.e., the project directory, not the
src
directory or default package directory, if you are using
Eclipse) so that this directory has a file in it. (You can use another file
if you like, and you can have more than one file in the working directory,
just make sure they do not have a size of 0.)
DirectoryListing
class.
DirectoryListing
class.
DirectoryListing
class so that it
prints the size of each file next to the name. (Hint: Use the
length()
method.)
What code did you add?
DirectoryListing
class.
DirectoryListing
class --
you will need to use what you learned from it in the following
steps.
DirectorySizeCalculator
class.
File
class and convince/remind yourself that there are two different kinds of
File
objects, "directories" and "normal files".
search(File)
method
in the DirectorySizeCalculator
class, what is the easy case?
i
is the easy case?
Searcher
class.
search()
method use to
shrink the search space?
first
and last
, and letting the
quarters be defined by first
to a
,
a+1
to b
, b+1
to c
,
and c
to last
, write expressions for
a
, b
, and c
. (Hint:
Calculate b
(i.e., the middle index) first and then use
it to calculate a
and c
.)
first
is 0 and last
is 8.
What are a
, b
, and c
?
a
, b
, and c
what would the four calls to the search()
method be? (Note: Don't use variables, use literals.)
first
is 0 and last
is 2.
What are a
, b
, and c
?
a
, b
, and c
what would the four calls to the search()
method be? (Note: Don't use variables, use literals.)
Copyright 2021