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:
downloads directory/folder). In most browsers/OSs, the
easiest way to do this is by right-clicking/control-clicking on
each of the links above and then selecting lab02) under the src directory.
TripRecord.java to the directory/folder that you
just created. (Note: This version is different from the version that
you might have used in an earlier lab.)
in the activity bar. (This
will open the explorer view in the primary side bar.)
CS159, src, and the
directory/folder you created for this lab.
TripRecord.java by
double-clicking on the file with that name in the explorer view.
yes package statement so that it is consistent
with the directory/folder you created for this lab (e.g.,
package lab02;) and save the file.
.java file is said to contain "source code". What
is "source code"?
.java file is compiled, the resulting "object
code" is put in a .class file. What is "object code"?
.java files that they need to
include in a project?
.java files that have
been given to them?
.class files that they need to
include in a project?
.class files that have
been given to them?
.class file rather than
a .java file?
.class files wants to
organize/group them, how can they do it?
.jar files?
trips.jar that
you downloaded earlier into the lib directory for this
course. It contains a file named TripBoard.class.
src
directory/folder) and pull down to
New File....
Tripping.java in the text field.
package
statement and class declaration.
/**
* The main class for the Tripping application that displays
* information about trips that have been taken by a fleet
* of passenger vehicles.
*/
@author and @version line to this
block comment. What lines did you add?
main() method with a formal parameter
named args to the Tripping class. What
lines did you add?
main() method.
/**
* The entry point of the application.
*
* @param args The command-line arguments (which are ignored)
*/
args an instance attribute, a class attribute, a
formal parameter, or a local variable?
args?
main() method that declares
a TripBoard object named board. What
code did you add?
TripBoard cannot be resolved to a type because
you have not told the compiler where to find the .class
file. To resolve this error, add the following import statement
below the package statement.import lab02.gui.TripBoard;
VSCode looks in the lib directory/folder for
.jar files, and the TripBoard class
is in the package lab02.gui in trip.jar.
board an instance attribute, a class attribute,
a formal parameter, or a local variable?
main() method that declares
a TripRecord object named rec. What
code did you add?
TripRecord cannot be resolved to a type, then
Tripping.java or TripRecord.java is
not in the correct directory/folder.
TripBoard class has a constructor that is passed
a String containing the company name.
Add a statement that constructs a TripBoard object
(using command-line argument 0 for the company name) and
assigns it to the variable named board. What
code did you add?
TripRecord object
(with 3 passengers, 5.9 hours, and 355.0 miles), and
assigns it to the variable named rec. What
code did you add?
TripBoard class has a method
named addTripRecord() that has a single formal
parameter of type TripRecord and that doesn't
return anything. Add rec to board
using this method. What code did you add?
. in the statement you just added?
TripRecord object
(with 2 passengers, 2.1 hours, and 143.1 miles), and
assigns it to the variable named rec. What
code did you add?
rec to board using this
method. What code did you add?
(near the top right of the VSCode
window). What happens?
args in the
main() method.
main()?
lab02.Tripping) and paste it into last line
of the Terminal window. Then, type a space and the command line
argument SafeRides and
press Return. What happens?
TripRecord. However, you're not sure and you
don't want to re-type them if you don't have to. So, click and
drag to select those lines. What happens?
Copyright 2024