Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,15 @@
% ********** This will generate jjj-os.pdf
% ********** First change into the source files directory
% 0) cd texfiles
% 1) pdflatex -shell-escape jjj-os
% 2) pdflatex -shell-escape jjj-os
% 3) mv jjj-os.pdf ../jjj-os.pdf
% 1) ./makepdf.sh
% **********
% **********

% ********** If you made major changes and you
% ********** want to start clean...
% ********** First change into the source files directory
% 0) cd texfiles
% 1) ./cleanpdf.sh
% 2) ./makepdf.sh
% **********
% **********
12 changes: 12 additions & 0 deletions README~
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
% book Morelli
% **********
% ********** How to generate a PDF into this directory
% ********** This will generate jjj-os.pdf
% ********** First change into the source files directory
% 0) cd texfiles
% 1) makeindex jjj-os
% 2) latex jjj-os
% 3) dvips -f jjj-os.dvi > ../jjj-os.ps
% 4) ps2pdf ../jjj-os.ps ../jjj-os.pdf
% **********
% **********
Binary file added chptr00/chesshier.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added chptr03/drawsticks.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1,815 changes: 1,814 additions & 1 deletion chptr05/5f1.eps

Large diffs are not rendered by default.

Binary file added chptr14/artwork/pongdesign.odt
Binary file not shown.
Binary file added chptr14/artwork/pongdesign.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added chptr14/pongdesign-sm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added chptr14/pongdesign.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1,099 changes: 1,098 additions & 1 deletion chptr15/p830f1.eps

Large diffs are not rendered by default.

1,074 changes: 1,073 additions & 1 deletion chptr15/p830f2.eps

Large diffs are not rendered by default.

910 changes: 909 additions & 1 deletion chptr15/p832f1.eps

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
18 changes: 18 additions & 0 deletions java-sourcecode/ch15/sound/Read.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

Hello,


Stock audio - Free sound effects, loops and music.


There are no hidden costs or need to sign-up.


Artist: Kevin Macleod

Song: Local Forecast - Elevator Music
Filename:liftMusic.mp3

Licence: TThe song is permitted for commercial use under license "Attribution 3.0 Unported (CC BY 3.0)"

http://www.orangefreesounds.com/
Binary file added java-sourcecode/ch15/sound/SoundClip.class
Binary file not shown.
50 changes: 50 additions & 0 deletions java-sourcecode/ch15/sound/SoundClip.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import javax.sound.sampled.*;
import java.net.URL;
import java.net.MalformedURLException;
import java.io.IOException;

public class SoundClip {

public static void main(String[] args) {
int times = 1;
Clip clip;
URL url = null;
try {
url = new
URL("http://cooplogic.com/cheyney/sound/liftMusic.wav");
AudioInputStream audio =
AudioSystem.getAudioInputStream(url); // get stream from url
DataLine.Info info = new DataLine.Info(Clip.class,
audio.getFormat()); // info needed for line

if (!AudioSystem.isLineSupported(info)) {
System.err.println("Audio file not supported: " +
info);
return;
}
try {
clip = (Clip) AudioSystem.getLine(info); // the clip does the work
clip.open(audio); // open the stream.
clip.start(); // start the stream on a separate thread.
// loop until clip has finished
while (clip.getFramePosition() < clip.getFrameLength()) {
try {
Thread.sleep(10);
} catch (Exception e) {
e.printStackTrace();
}
}
} catch (LineUnavailableException ex) {
ex.printStackTrace();
}

} catch (MalformedURLException e) {
System.out.println("Malformed URL: " + url.toString()) ;
} catch (UnsupportedAudioFileException ae) {
System.out.println("not supported: " + ae) ;
} catch (IOException ioex) {
ioex.printStackTrace();
}

}
}
Binary file added java-sourcecode/ch15/sound/liftMusic.mp3
Binary file not shown.
Binary file added java-sourcecode/ch15/sound/liftMusic.wav
Binary file not shown.
Binary file added java-sourcecode/ch3/drawsticks/DisplayFrame.class
Binary file not shown.
41 changes: 41 additions & 0 deletions java-sourcecode/ch3/drawsticks/DisplayFrame.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import java.awt.Canvas;
import javax.swing.JFrame;

public class DisplayFrame {
// every java program needs a main to run!
public static void main(String[] args){
if (args.length < 1) {
System.out.println("Usage: java DisplayFrame <FrameClassName>" +
" [ width height]");
return;
}
int width = 400;
int height = 400;
try {
if (args.length == 3) {
width = Integer.parseInt(args[1]);
height = Integer.parseInt(args[2]);
}
Class c = Class.forName(args[0]);
JFrame f = null;
if (c.getSuperclass() == Canvas.class) {
Canvas can = (Canvas) c.newInstance();
f = new JFrame(args[0]);
f.add(can);
} else if (c.getSuperclass() == JFrame.class) {
f = (JFrame) c.newInstance();
}
if (f != null) {
f.setSize(width,height);
f.setVisible(true);
}
} catch(InstantiationException e) {
e.printStackTrace();
} catch(ClassNotFoundException cnfe) {
cnfe.printStackTrace();
} catch(IllegalAccessException iae) {
iae.printStackTrace();
}
}

}
Binary file not shown.
43 changes: 43 additions & 0 deletions java-sourcecode/ch3/drawsticks/DrawSticksCanvas.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* File: DrawSticksApplet.java
* Author: Java Java Java
* Description: This applet uses Java's built-in
* drawing methods to draw vertical lines on its window.
* It draws a set of 12 vertical lines and a set of 7 lines.
*/

import java.awt.*;
import javax.swing.*;

public class DrawSticksCanvas extends Canvas
{
/** drawSticks(g,x,y,num) will draw num vertical line
* segments. The line segments are 10 pixels apart and
* 50 pixels long. The top endpoint of the left most
*line segment is at the point (x,y).
*/
public void drawSticks(Graphics g, int x, int y, int num)
{ int k = 0;
while (k < num)
{ g.drawLine(x, y, x, y + 50);
x = x + 10;
k = k + 1;
} // while
} // drawSticks()

public void paint(Graphics g)
{ drawSticks(g, 25, 25, 12);
g.setColor(Color.cyan);
drawSticks(g, 25, 125, 7);
} // paint()

// every java program needs a main to run!
public static void main(String[] args){
DrawSticksCanvas c = new DrawSticksCanvas();
JFrame f = new JFrame("Draw Sticks Program");
f.add(c);
f.setSize(200,200);
f.setVisible(true);
}

} // DrawSticksCanvas
Binary file added java-sourcecode/ch8/toggle/ToggleButton.class
Binary file not shown.
Binary file added java-sourcecode/ch8/toggle/ToggleFrame.class
Binary file not shown.
25 changes: 25 additions & 0 deletions java-sourcecode/ch8/toggle/ToggleFrame.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class ToggleFrame extends JFrame
implements ActionListener {
private ToggleButton lightSwitch;

public ToggleFrame() {
lightSwitch = new ToggleButton ("off","on");
getContentPane().add(lightSwitch);
lightSwitch.addActionListener(this);
} // init()

public void actionPerformed(ActionEvent e) {
setTitle("The light is " + lightSwitch.getText());
} // actionPerformed()

public static void main(String args[])
{
JFrame f = new ToggleFrame();
f.setSize(200,200);
f.setVisible(true);
}
} // ToggleFrame
Binary file modified jjj-os.pdf
Binary file not shown.
42 changes: 21 additions & 21 deletions texfiles/0.intro.tex
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ \section{Welcome}
{A diagram of the main functional
components in a computer system. The arrows indicate the flow of information
between various components.
\label{fig-blockdiagram}}
} {fig-blockdiagram}
%\end{graphic}
\end{figure}

Expand Down Expand Up @@ -299,7 +299,7 @@ \section{Networks, the Internet and the World Wide Web}
{WWW: The client's browser requests a page from
a Web server. When the HTML document is returned, it is
interpreted and displayed by the browser.
\label{fig-http}}
} {fig-http}
%\end{graphic}
\end{figure}

Expand Down Expand Up @@ -489,8 +489,8 @@ \section{Programming Languages}
\figaright{chptr00/0f3.eps}
{Translator software translates high-level
{\it source code} to machine language {\it object code}.
\label{fig-translator}
\label{pg-fig-translator}}
} {fig-translator}

%\end{graphic}
\end{figure}

Expand Down Expand Up @@ -606,13 +606,13 @@ \section{Why Java?}
programmers.

For example, we will work on projects throughout the text that involve
games and puzzles. We start out in Chapter~2 by designing very simple
games and puzzles. We start out in Chapter~\ref{chapter-objects} by designing very simple
games that involve storing and retrieving data. As we learn more
sophisticated programming techniques, we gradually build more
complexity into the games and puzzles. For example, we learn how to
create interactive, two-person games in Chapter~4. In Chapter~8, we
create interactive, two-person games in Chapter~\ref{chapter-io}. In Chapter~\ref{chapter-inheritance}, we
develop some games and puzzles that are played on virtual game boards.
Finally, in Chapter~14 we learn how to introduce games with multiple
Finally, in Chapter~\ref{chapter-threads} we learn how to introduce games with multiple
players on different computers. To get a look at where we are headed
you might want to visit the authors' companion Web site:

Expand Down Expand Up @@ -689,8 +689,8 @@ \subsection{What is an Object?}
\figaleft{chptr00/umlobj1.eps} {In UML, objects are represented by
rectangles that are labeled with a two-part label of the form {\it
id:Type}. The object's label is always underlined.
\label{fig-umlobj1}
\label{pg-fig-umlobj1}}
} {fig-umlobj1}

\end{figure}

\subsection{Attributes and Values}
Expand All @@ -714,8 +714,8 @@ \subsection{Attributes and Values}
\figaleft{chptr00/umlobj2.eps}
{A second partition of an object diagram is used to display
the object's attributes and their values.
\label{fig-umlobj2}
\label{pg-fig-umlobj2}}
} {fig-umlobj2}

\end{figure}

We sometimes refer to the collection of an object's attributes and
Expand All @@ -741,8 +741,8 @@ \subsection{Actions and Messages}
\figaright{chptr00/umlmsg1.eps} {Messages in UML are represented by labeled
arrows. In this example, we are telling a pawn to move from its
current position to row 3 column 4.
\label{fig-umlmsg1}
\label{pg-fig-umlmsg1}}
} {fig-umlmsg1}

\end{figure}

The actions that are associated with an object can be used to send
Expand Down Expand Up @@ -821,8 +821,8 @@ \subsection{What is a Class?}
\begin{figure}[tb]
\figaleft{chptr00/rectclass.eps}
{A UML diagram of the {\tt Rectangle} class.
\label{fig-umlrect}
\label{pg-fig-umlrect}}
} {fig-umlrect}

\end{figure}

Figure~\ref{fig-umlrect} shows a UML diagram of our {\tt Rectangle}
Expand Down Expand Up @@ -903,8 +903,8 @@ \subsection{Instance versus Class Variables and Methods}
instances. Note that the class variable, {\tt nRectangles}, is
underlined to distinguish it from {\tt length} and {\tt width}, the
instance variables.
\label{fig-rects}
\label{pg-fig-rects}}
} {fig-rects}

\end{figure}

Figure~\ref{fig-rects} illustrates these concepts. Note that class
Expand All @@ -931,8 +931,8 @@ \subsection{Instance versus Class Variables and Methods}
\begin{figure}[h]
\figaleftscaled{chptr00/rectconstr.eps}{0.8}
{Constructing a {\tt Rectangle} instance.
\label{fig-rectconstr}
\label{pg-fig-rectconstr}}
} {fig-rectconstr}

\end{figure}

\subsection{Class Hierarchy and Inheritance}
Expand Down Expand Up @@ -1005,8 +1005,8 @@ \subsection{Class Hierarchy and Inheritance}
\begin{figure}[tb]
\figaleft{chptr00/chesshier-small.png}
{The {\tt ChessPiece} hierarchy.
\label{fig-chesshier}
\label{pg-fig-chesshier}}
} {fig-chesshier}

\end{figure}

One of the actions that all chess pieces have in common is that they
Expand Down
24 changes: 12 additions & 12 deletions texfiles/1.programs.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1654,7 +1654,6 @@ \subsection{The {\tt import} Statement}
\noindent allows all classes in the {\tt java.lang} package to
be referred to by their class names alone. In fact, this particular
{\tt import} statement is implicit in every Java program.

\subsection{Qualified Names in Java}
\label{subsec:qualifiednames}

Expand Down Expand Up @@ -1740,32 +1739,33 @@ \subsection{Java Development Environments}
\noindent A Java programming environment typically consists of several
programs that perform different tasks required to edit, compile, and
run a Java program. The following description will be based on the
software development environment provided by Sun Microsystems, the
company that developed Java. It is currently known as the {\it Java2
Platform, Standard Edition 5.0 (J2SE 5.0)}. Versions of J2SE are
software development environment provided by Oracle, the
company that owns and maintains Java. It is currently known as the {\it Java
Platform, Standard Edition 8.0 (Java SE 8)}. Versions of Java SE are
available for various platforms, including Linux, Windows, and
macOS computers. Free downloads are available at Sun's Web site
at {\tt http://java.sun.com/j2se/}. (For more details about the J2SE,
at {\tt http://www.oracle.com/technetwork/java/}. (For more details
about the Java SE,
see Appendix~\ref{appendix-jdk}.)

In some cases, the individual programs that make up the J2SE are
In some cases, the individual programs that make up the Java SE are
available in a single program development environment, known as an
{\it integrated development environment (IDE)}. Some examples include
Metrowerk's Codewarrior, Borland's JBuilder, and Sun's own NetBeans
Eclipse, jGrasp, and Oracle's own NetBeans
IDE. Each of these provides a complete development package for
editing, compiling, and running Java applications and applets on
a variety of platforms, including Linux and Windows.
editing, compiling, and running Java applications on
a variety of platforms, including Linux, macOS, and Windows.

Figure~\ref{fig:compile} illustrates the process involved in creating
and running a Java program. The discussion that follows here assumes
\begin{figure}[tb]
\figaleft{chptr01/compile.eps}{Editing, compiling, and running
%%%\figa{chptr01/compile.eps}{Editing, compiling, and running
{\tt HelloWorld.java}.
\label{fig:compile}}
} {fig:compile}

\end{figure}
that you are using the J2SE as your development environment to edit,
that you are using the Java SE as your development environment to edit,
compile and run the example program. If you are using some other
environment, you will need to read the documentation provided with the
software to determine exactly how to edit, compile, and run Java
Expand Down Expand Up @@ -1819,7 +1819,7 @@ \subsection{Compiling a Program}
program, whether an applet or an application, the JVM is then used to
interpret and execute the bytecode.

The J2SE comes in two parts, a runtime program, called the {\it Java
The Java SE comes in two parts, a runtime program, called the {\it Java
Runtime Environment (JRE)} and a development package, called the {\em
Software Development Kit (SDK)}. If you are just going to run Java
programs, you need only install the JRE on your computer. In order to
Expand Down
Loading