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 String
class may be referred to as
the java.lang.String
class and the Scanner
class may be referred to as the java.util.Scanner
class.
String
class.
String
named course
?
course
above (so that it contains the letters "CS100"
)?
String
class contain any methods that begin
with set
?
String
class contains some methods that make it
look like String
objects are mutable. Name some of them.
void
? If not, what do they return?
String
objects mutable?
TextEditor
class. (Note: It is in the package editor
).
TextEditor
named editor
?
editor
above (using the default constructor)?
public void selectAll()that belongs to the object named
editor
?
TextEditor
objects mutable or immutable?
JMUview.java
that contains the following "shell":
import editor.*; /** * The driver for JMUview -- a simple command-line argument viewer * * @author Your Name * @version 1.0 */ public class JMUview { /** * The entry point for JMUview * * @param args The command-line arguments */ public static void main(String[] args) { } }
and replace "Your Name" with the appropriate text.
main()
method that:
TextEditor
named editor
.
TextWindow
named window
.
editor
using
the default constructor.
setShouldHaveScrollBar()
method of
editor
passing the boolean
literal
true
.
setEditable()
method of
editor
passing the boolean
literal
false
.
window
passing
the String
literal "JMUview" to the explicit value
constructor.
setTextEditor()
method of
window
passing the object
editor
.
setText()
method of the
editor
object, passing it
"No command-line arguments."
. Otherwise, it iteratively
calls the append()
method of the editor
object twice (per iteration), first passing the command-line
argument and then passing a newline character.
setVisible()
method of
window
passing the boolean
literal
true
. (Note: The call to setVisible()
must be the last method call on the window
object.)
JMUview.java
.
JMUview
passing it no command-line arguments.
JMUview
passing it several command-line arguments.
JMUedit
(with appropriate
documentation) that has, at a minimum,
a method with the signature:
public static void main(String[] args)
Your implementation must:
TextEditor
object.
TextEditor
object it should be "editable".
TextEditor
object it should have a scrollbar.
TextWindow
object
with the title "JMUedit".
TextWindow
object it should use
the TextEditor
object you already constructed.
TextWindow
object that it should
ask the user to confirm exit requests.
TextWindow
object to add a "File" menu.
TextWindow
object it should be visible.
JMUedit.java
.
JMUedit
, navigate to a directory/folder that
contains a text file, and open it.
JMUedit
and make sure that it "confirms".
JMUedit
again type some text. Then, make
sure that you can save the text to a file.
JMUlti
that has, at a minimum,
a method with the signature:
public static void main(String[] args)
Your implementation must satisfy the following requirements:
int
variable named number
to 1; If there are
command-line arguments, it must convert args[0]
to an int
value using the
static parseInt(String)
method in
the Integer
class and assign this value to
an int
variable named number
.
number
different
TextWindow
objects
(each containing a unique TextEditor
object).
Note: The technique you use must be appropriate for constructing
any number of objects. In other words, use a loop.
TextEditor
must be editable and have a scrollbar.
TextWindow
must confirm on exit, have a "File"
menu, and be visible.
TextWindow
must have its own title
that includes the text "JMUlti -- Window" and the appropriate number
between 0 and number - 1
. (Hint: You can use
String
concatenation or the static
method named format()
in the String
class
that works just like the printf()
method but, instead
of printing an appropriately formatted String
, returns
one.)
TextEditor
must initially contain the text
"JMUlti -- Window" and a number (between 0
and number - 1
). This text should be selected (so
that it will be replaced when the user enters new text).
TextEditor
and TextWindow
objects?
TextEditor
and TextWindow
objects, what
would you do?
JMUlti.java
.
JMUlti
with no command-line arguments.
JMUlti
.
JMUlti
with a small numeric command-line
argument. (Note: The windows may open "on top of"
each other, so you may have to move one to see the others).
JMUlti
. (Note: Closing one window will
cause the application to exit. Hence, all of the other windows
will also close.)
JMUlti.java
in such a way that
the main()
method iteratively invokes a private
static
"helper" method named createWindow()
that
is passed an int
and constructs a single
TextWindow
containing a TextEditor
with all
of the same properties as in the existing implementation.
Copyright 2024