forked from ChrisMayfield/ThinkJava2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
thinkjava2.tex
295 lines (190 loc) · 5.77 KB
/
thinkjava2.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
\documentclass[12pt]{book}
\title{Think Java}
\author{Allen B. Downey and Chris Mayfield}
\newcommand{\thetitle}{Think Java}
\newcommand{\thesubtitle}{How to Think Like a Computer Scientist}
\newcommand{\theauthors}{Allen B. Downey and Chris Mayfield}
\newcommand{\theversion}{2nd Edition, Version 7.1.0}
%%%% Both LATEX and PLASTEX
\usepackage{graphicx}
\usepackage{setspace}
% automatically index glossary terms
\newcommand{\term}[1]{%
\item[#1:]\index{#1}}
\usepackage{amsmath}
\usepackage{amsthm}
% format end of chapter excercises
\newtheoremstyle{exercise}
{12pt} % space above
{12pt} % space below
{} % body font
{} % indent amount
{\bfseries} % head font
{} % punctuation
{12pt} % head space
{} % custom head
\theoremstyle{exercise}
\newtheorem{exercise}{Exercise}[chapter]
\newif\ifplastex
\plastexfalse
%%%% PLASTEX ONLY
\ifplastex
\makeindex
\usepackage{localdef}
\usepackage{url}
\renewcommand{\href}[2]{\url{#1}}
\makeatletter
\newcount\anchorcnt
\newcommand*{\Anchor}[1]{%
\@bsphack%
\Hy@GlobalStepCount\anchorcnt%
\edef\@currentHref{anchor.\the\anchorcnt}%
\Hy@raisedlink{\hyper@anchorstart{\@currentHref}\hyper@anchorend}%
\M@gettitle{}\label{#1}%
\@esphack%
}
\makeatother
% code listing environments:
% we don't need these for plastex because they get replaced
% by preprocess.py
%\newenvironment{code}{\begin{verbatim}}{\end{verbatim}}
%\newenvironment{stdout}{\begin{verbatim}}{\end{verbatim}}
% inline syntax formatting
%\newcommand{\java}{\verb}%}
%\newcommand{\java}{\texttt}%}
\newcommand{\java}[1]{{\tt #1}}%{
\newcommand{\textcolor}[1]{\relax}
%%%% LATEX/HTML ONLY
\else
%BEGIN LATEX
\usepackage{comment}
\excludecomment{htmlonly}
\includecomment{latexonly}
%END LATEX
\input{latexonly.tex}
\fi
%%%% END OF PREAMBLE
\begin{document}
\frontmatter
%%%% PLASTEX ONLY
\ifplastex
\maketitle
%%%% LATEX/HTML ONLY
\else
\begin{latexonly}
%--half title-------------------------------------------------
\thispagestyle{empty}
\begin{flushright}
\vspace*{2.0in}
\begin{spacing}{3}
{\huge \thetitle} \\
{\Large \thesubtitle}
\end{spacing}
\vspace{0.25in}
\theversion
\vfill
\end{flushright}
%--verso------------------------------------------------------
\newpage
\thispagestyle{empty}
\quad
%--title page-------------------------------------------------
\newpage
\thispagestyle{empty}
\begin{flushright}
\vspace*{2.0in}
\begin{spacing}{3}
{\huge \thetitle} \\
{\Large \thesubtitle}
\end{spacing}
\vspace{0.25in}
\theversion
\vspace{1in}
{\Large \theauthors}
\vspace{0.5in}
{\Large Green Tea Press}
{\small Needham, Massachusetts}
\vfill
\end{flushright}
%--copyright--------------------------------------------------
\newpage
\thispagestyle{empty}
Copyright \copyright ~2020 \theauthors.
\vspace{0.2in}
\begin{flushleft}
Green Tea Press \\
9 Washburn Ave \\
Needham, MA 02492
\end{flushleft}
Permission is granted to copy, distribute, and/or modify this work under the terms of the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License, which is available at \url{https://creativecommons.org/licenses/by-nc-sa/4.0/}.
The original form of this book is \LaTeX\ source code.
Compiling this code has the effect of generating a device-independent representation of the book, which can be converted to other formats and printed.
The \LaTeX\ source for this book is available from \url{https://thinkjava.org/} and \url{https://github.com/ChrisMayfield/ThinkJava2}.
%--table of contents------------------------------------------
\cleardoublepage
\setcounter{tocdepth}{1}
\tableofcontents
\end{latexonly}
%--HTML title page--------------------------------------------
\begin{htmlonly}
\vspace{1em}
{\Large \thetitle: \thesubtitle}
{\large \theauthors}
\theversion
\vspace{1em}
Copyright \copyright ~2020 \theauthors.
Permission is granted to copy, distribute, and/or modify this work under the terms of the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License, which is available at \url{https://creativecommons.org/licenses/by-nc-sa/4.0/}.
\vspace{1em}
\end{htmlonly}
%-------------------------------------------------------------
%%%% END OF THE PART WE SKIP FOR PLASTEX
\fi
\input{ch00.tex}
\mainmatter
%~ \part{Programming Fundamentals}
\input{ch01.tex}
\input{ch02.tex}
\input{ch03.tex}
\input{ch04.tex}
\input{ch05.tex}
\input{ch06.tex}
\input{ch07.tex}
\input{ch08.tex}
%~ \part{Object-Oriented Programming}
\input{ch09.tex}
\input{ch10.tex}
\input{ch11.tex}
\input{ch12.tex}
\input{ch13.tex}
\input{ch14.tex}
\input{ch15.tex}
\input{ch16.tex}
\input{ch17.tex}
\appendix
%\addtocontents{toc}{\protect\newpage}
%~ \part{Appendixes}
%BEGIN LATEX
\renewcommand{\chaptermark}[1]{\markboth{Appendix \thechapter ~~ #1}{}}
%END LATEX
\input{appa.tex}
\input{appb.tex}
\input{appc.tex}
\input{appd.tex}
\backmatter
\printindex
%-------------------------------------------------------------
\ifplastex
\else
\newpage
\thispagestyle{empty}
\vspace*{64pt}
{\bf\huge About the Authors}
\vspace*{40pt}
{\bf Allen Downey} is a professor of computer science at Olin College of Engineering.
He has taught computer science at Wellesley College, Colby College, and UC Berkeley.
He has a PhD in computer science from UC Berkeley and master's and bachelor's degrees from MIT.
Allen is the creator of the best-selling Think series for O'Reilly, which includes {\it Think Python}, {\it Think Complexity}, {\it Think DSP}, and {\it Think Bayes}.
{\bf Chris Mayfield} is an associate professor of computer science at James Madison University, with a research focus on CS education and professional development.
He has a PhD in computer science from Purdue University and bachelor's degrees in CS and German from the University of Utah.
\fi
\end{document}