From the standpoint of a software engineer, carefully and concisely define the term "computer". |
(1) |
From the standpoint of a software engineer, what differentiates a "mobile computer" from any other "computer". |
(2) |
In J2ME, what is a "profile"? |
(3) |
What is BREW? |
(4) |
Why are traditional GUI tool/widget sets (e.g., AWT, Swing) not appropriate for many mobile computing devices? |
(5) |
Displayable
that, when displayed, will
look something like the following:
Command
objects.clearPhrase()
method that
clears the phrase.translatePhrase()
method that is passed String
objects for
the two languages and the phrase to be translated.
Translator
class that can be used to
translate a phrase in a separate thread of execution.
(Note: You should not implement a working translation algorithm. The
translation algorithm should simply append the String
"[translated]" to the phrase.
translatePhrase()
method. Your implementation
must:
Translator()
object.Translator()
object
to perform the translation in a separate thread of
execution.
translatePhrase()
method aboce. Discuss the advantages and disadvantages of each.
Which would you use?
Question
below uses the two
classes TickReader
and TickWriter
. Trace
the execution of this application by writing numbers/letters next to
each line indicating the thread it is executed in and the order in
which it is executed. Lines in the first thread should be numbered
using 1,2,3... Lines in the second thread (if there is one) should
be numbered using A,B,C... Lines in the third thread (if there is
one) should be numbered using a,b,c...
import java.io.*; /** * The application * */ public class Question { /** * The entry point of the application * * @param args The array of command-line arguments */ public static void main(String[] args) { BufferedReader br; FileReader fr; PrintWriter pw; TickReader in; TickWriter file, screen; try { fr = FileReader("question.tik"); br = new BufferedReader(fr); in = new TickReader(br); pw = new PrintWriter(System.out, true); screen = new TickWriter(pw); in.setTickObserver(screen); in.readTick(); screen.start(); in.readTick(); } catch (Exception exception) { System.err.println(exception); } } }
import java.io.*; import java.util.*; /** * A class for reading Tick information from a BufferedReader * */ public class TickReader { protected BufferedReader reader; protected TickWriter observer; /** * Construct a new TickReader * * @param reader The BufferedReader to read from */ public TickReader(BufferedReader reader) { this.reader = reader; observer = null; } /** * Set the observer * * @param observer The new observer */ public void setTickObserver(TickWriter observer) { this.observer = observer; } /** * Notify the observer of a Tick * * @param tick The tick to notify them of */ public void notifyTickObserver(String tick) { observer.handleTickNotification(tick); } /** * Read one Tick object and notify the observer * */ public void readTick() throws IOException { String tick; tick = reader.readLine(); notifyTickObserver(tick); } }
import java.io.*; import java.util.*; /** * A class for writing Tick information to a PrintWriter */ public class TickWriter implements Runnable { protected LinkedList queue; protected PrintWriter writer; protected Thread ctrl; /** * Construct a new TickWriter * * @param Writer The BufferedWriter to use */ public TickWriter(PrintWriter writer) { this.writer = writer; queue = new LinkedList(); ctrl = new Thread(this) } /** * Handle notification from a TickReader * * @param tick The tick to be handled */ public void handleTickNotification(String tick) { queue.addLast(tick); } /** * Print the tick on the writer * * @param tick The tick to print */ private void printTick(String tick) { writer.println(tick); } /** * Code to run in the control thread */ public void run() { String tick; if (queue.size() > 0) { tick = (String)(queue.removeFirst()); printTick(tick); } } } /** * Starts the control Thread */ public void start() { ctrl.start(); }The file
question.tik
contains
the following information:
MSFT,STOCK,129.175,b C1997Z,FUTURE,253.3,a MSFT,STOCK,130.175,s
Copyright 2007