0% found this document useful (0 votes)
36 views62 pages

Head First C Andrew Stellman Jennifer Greene Download

The document provides information about various educational books, particularly focusing on 'Head First C#' by Andrew Stellman and Jennifer Greene, which is designed to make learning C# engaging and effective. It includes details about the authors, the book's structure, and its approach to teaching programming concepts. Additionally, it lists other related books in the Head First series and offers links for downloading them.

Uploaded by

govrocertax0
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views62 pages

Head First C Andrew Stellman Jennifer Greene Download

The document provides information about various educational books, particularly focusing on 'Head First C#' by Andrew Stellman and Jennifer Greene, which is designed to make learning C# engaging and effective. It includes details about the authors, the book's structure, and its approach to teaching programming concepts. Additionally, it lists other related books in the Head First series and offers links for downloading them.

Uploaded by

govrocertax0
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 62

Head First C Andrew Stellman Jennifer Greene

download

https://textbookfull.com/product/head-first-c-andrew-stellman-
jennifer-greene/

Download more ebook from https://textbookfull.com


We believe these products will be a great fit for you. Click
the link to download now, or visit textbookfull.com
to discover even more!

Head First Agile A Brain Friendly Guide to Agile and


the PMI ACP Certification 1st Edition Andrew Stellman

https://textbookfull.com/product/head-first-agile-a-brain-
friendly-guide-to-agile-and-the-pmi-acp-certification-1st-
edition-andrew-stellman/

Pmp A Learner s Companion to Passing the Project


Management Professional Exam Jennifer Greene

https://textbookfull.com/product/pmp-a-learner-s-companion-to-
passing-the-project-management-professional-exam-jennifer-greene/

Microbiology for Dummies 1st Edition Jennifer C.


Stearns

https://textbookfull.com/product/microbiology-for-dummies-1st-
edition-jennifer-c-stearns/

Scott-Brown’s Otorhinolaryngology and Head and Neck


Surgery. Volume 3: Head and Neck Surgery, Plastic
Surgery John C Watkinson

https://textbookfull.com/product/scott-browns-
otorhinolaryngology-and-head-and-neck-surgery-volume-3-head-and-
neck-surgery-plastic-surgery-john-c-watkinson/
Scott-Brown’s Otorhinolaryngology and Head and Neck
Surgery: Volume 3: Head and Neck Surgery, Plastic
Surgery John C Watkinson

https://textbookfull.com/product/scott-browns-
otorhinolaryngology-and-head-and-neck-surgery-volume-3-head-and-
neck-surgery-plastic-surgery-john-c-watkinson-2/

Head First Learn to Code 1st Edition Eric Freeman

https://textbookfull.com/product/head-first-learn-to-code-1st-
edition-eric-freeman/

Flight risk a novel First Edition Jennifer Fenn

https://textbookfull.com/product/flight-risk-a-novel-first-
edition-jennifer-fenn/

Head First Python A Brain Friendly Guide 2nd Edition


Paul Barry

https://textbookfull.com/product/head-first-python-a-brain-
friendly-guide-2nd-edition-paul-barry/

Ghouls Revenants Jason Andrew Bill Bodden Jennifer Coy


Dhaunae De Vir Matt M Mcelroy Karen Needham Andrew
Peregrine Matthew Sanderson Monica Valentinelli

https://textbookfull.com/product/ghouls-revenants-jason-andrew-
bill-bodden-jennifer-coy-dhaunae-de-vir-matt-m-mcelroy-karen-
needham-andrew-peregrine-matthew-sanderson-monica-valentinelli/
Head First C#
FOURTH EDITION

Andrew Stellman

Jennifer Greene
Head First C#
Fourth Edition
by Andrew Stellman and Jennifer Greene
Copyright © 2021 Jennifer Greene, Andrew Stellman. All rights
reserved.
Printed in the United States of America.
Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North,
Sebastopol, CA 95472.
O’Reilly Media books may be purchased for educational, business, or
sales promotional use. Online editions are also available for most
titles (http://oreilly.com). For more information, contact our
corporate/institutional sales department: (800) 998-9938 or
[email protected].
Series Creators: Kathy Sierra, Bert Bates
Cover Designer: Ellie Volckhausen
Brain Image on Spine: Eric Freeman
Editors: Nicole Taché, Amanda Quinn
Proofreader: Rachel Head
Indexer: Potomac Indexing, LLC
Illustrator: Jose Marzan
Page Viewers: Greta the miniature bull terrier and Samosa the
Pomeranian
Printing History:
November 2007: First Edition.
May 2010: Second Edition.
August 2013: Third Edition.
December 2020: Fourth Edition

The O’Reilly logo is a registered trademark of O’Reilly Media, Inc.


The Head First series designations, Head First C#, and related trade
dress are trademarks of O’Reilly Media, Inc.
Microsoft, Windows, Visual Studio, MSDN, the .NET logo, Visual
Basic, and Visual C# are registered trademarks of Microsoft
Corporation.
Many of the designations used by manufacturers and sellers to
distinguish their products are claimed as trademarks. Where those
designations appear in this book, and O’Reilly Media, Inc., was aware
of a trademark claim, the designations have been printed in caps or
initial caps.
While every precaution has been taken in the preparation of this
book, the publisher and the authors assume no responsibility for
errors or omissions, or for damages resulting from the use of the
information contained herein.
No bees, space aliens, or comic book heroes were harmed in the
making of this book.
ISBN: 978-1-491-97670-8
[LSI]
[2020-11-13]
Praise for other Head First books
“I received the book yesterday and started to read it…and I couldn’t
stop. This is definitely très ‘cool.’ It is fun, but they cover a lot of
ground and they are right to the point. I’m really impressed.”
—Erich Gamma, IBM Distinguished Engineer, and coauthor
of Design Patterns
“One of the funniest and smartest books on software design I’ve
ever read.”

— Aaron LaBerge, SVP Technology & Product


Development, ESPN
“What used to be a long trial and error learning process has now
been reduced neatly into an engaging paperback.”

— Mike Davidson, former VP of Design, Twitter, and


founder of Newsvine
“Elegant design is at the core of every chapter here, each concept
conveyed with equal doses of pragmatism and wit.”
— Ken Goldstein, Executive VP & Managing Director,
Disney Online
“Usually when reading through a book or article on design patterns,
I’d have to occasionally stick myself in the eye with something just
to make sure I was paying attention. Not with this book. Odd as it
may sound, this book makes learning about design patterns fun.
“While other books on design patterns are saying ‘Bueller… Bueller…
Bueller…’ this book is on the float belting out ‘Shake it up, baby!’”
— Eric Wuehler
“I literally love this book. In fact, I kissed this book in front of my
wife.”

— Satish Kumar
Related books from O’Reilly
C# 8.0 in a Nutshell
C# 8.0 Pocket Reference
C# Database Basics
C# Essentials, 2nd Edition
Concurrency in C# Cookbook, 2nd Edition
Mobile Development with C#
Programming C# 8.0

Other books in O’Reilly’s Head First series


Head First 2D Geometry
Head First Agile
Head First Ajax
Head First Algebra
Head First Android Development
Head First C
Head First Data Analysis
Head First Design Patterns
Head First EJB
Head First Excel
Head First Go
Head First HTML5 Programming
Head First HTML with CSS and XHTML
Head First iPhone and iPad Development
Head First Java
Head First JavaScript Programming
Head First Kotlin
Head First jQuery
Head First Learn to Code
Head First Mobile Web
Head First Networking
Head First Object-Oriented Analysis and Design
Head First PHP & MySQL
Head First Physics
Head First PMP
Head First Programming
Head First Python
Head First Rails
Head First Ruby
Head First Ruby on Rails
Head First Servlets and JSP
Head First Software Development
Head First SQL
Head First Statistics
Head First Web Design
Head First WordPress
The Authors

Andrew Stellman, despite being raised a New Yorker, has lived in


Minneapolis, Geneva, and Pittsburgh…twice, first when he graduated
from Carnegie Mellon’s School of Computer Science, and then again
when he and Jenny were starting their consulting business and
writing their first book for O’Reilly.
Andrew’s first job after college was building software at a record
company, EMI-Capitol Records—which actually made sense, as he
went to LaGuardia High School of Music & Art and the Performing
Arts to study cello and jazz bass guitar. He and Jenny first worked
together at a company on Wall Street that built financial software,
where he was managing a team of programmers. Over the years
he’s been a vice president at a major investment bank, architected
large-scale real-time backend systems, managed large international
software teams, and consulted for companies, schools, and
organizations, including Microsoft, the National Bureau of Economic
Research, and MIT. He’s had the privilege of working with some
pretty amazing programmers during that time, and likes to think that
he’s learned a few things from them.
When he’s not writing books, Andrew keeps himself busy writing
useless (but fun) software, playing (and making) both music and
video games, practicing krav maga, tai chi, and aikido, and owning a
crazy Pomeranian.
Jennifer Greene studied philosophy in college but, like everyone
else in the field, couldn’t find a job doing it. Luckily, she’s a great
software engineer, so she started out working at an online service,
and that’s the first time she really got a good sense of what good
software development looked like.
She moved to New York in 1998 to work on software quality at a
financial software company. She’s managed teams of developers,
testers, and PMs on software projects in media and finance since
then.
Jenny has traveled all over the world to work with different software
teams and build all kinds of cool projects.
She loves traveling, watching Bollywood movies, reading the
occasional comic book, playing video games, and hanging out with
her huge Siberian cat, Sascha, and her miniature bull terrier, Greta.
Table of Contents (the real
thing)

1. Intro
Your brain on C#. You’re sitting around trying to learn
something, but your brain keeps telling you all that learning
isn’t important. Your brain’s saying, “Better leave room for
more important things, like which wild animals to avoid and
whether nude archery is a bad idea.” So how do you trick
your brain into thinking that your life really depends on
learning C#?

a. Who is this book for?


b. We know what you’re thinking.
c. And we know what your brain is thinking.
d. Metacognition: thinking about thinking
e. Here’s what WE did
f. Here’s what YOU can do to bend your brain into
submission
g. README
h. The technical review team
i. Acknowledgments
j. O’Reilly online learning
2. 1 start building with C#: Build something great…fast!
Want to build great apps…right now?
With C#, you’ve got a modern programming language
and a valuable tool at your fingertips. And with Visual
Studio, you’ve got an amazing development
environment with highly intuitive features that make
coding as easy as possible. Not only is Visual Studio a great
tool for writing code, it’s also a really valuable learning
tool for exploring C#. Sound appealing? Turn the page, and
let’s get coding.

a. Why you should learn C#


b. Visual Studio is a tool for writing code and exploring
C#
c. Create your first project in Visual Studio
d. Let’s build a game!
e. Here’s how you’ll build your game
f. Create a WPF project in Visual Studio
g. Use XAML to design your window
h. Design the window for your game
i. Set the window size and title with XAML properties
j. Add rows and columns to the XAML grid
k. Make the rows and columns equal size
l. Add a TextBlock control to your grid
m. Now you’re ready to start writing code for your game
n. Generate a method to set up the game
o. Finish your SetUpGame method
p. Run your program
q. Add your new project to source control
r. The next step to build the game is handling mouse
clicks
s. Make your TextBlocks respond to mouse clicks
t. Add the TextBlock_MouseDown code
u. Make the rest of the TextBlocks call the same
MouseDown event handler
v. Finish the game by adding a timer
w. Add a timer to your game’s code
x. Use the debugger to troubleshoot the exception
y. Add the rest of the code and finish the game
z. Update your code in source control
3. 2 dive into C#: Statements, classes, and code
You’re not just an IDE user. You’re a developer.
You can get a lot of work done using the IDE, but there’s
only so far it can take you. Visual Studio is one of the most
advanced software development tools ever made, but a
powerful IDE is only the beginning. It’s time to dig in to
C# code: how it’s structured, how it works, and how you
can take control of it…because there’s no limit to what you
can get your apps to do.

a. Let’s take a closer look at the files for a console app


b. Two classes can be in the same namespace (and
file!)
c. Statements are the building blocks for your apps
d. Your programs use variables to work with data
e. Generate a new method to work with variables
f. Add code that uses operators to your method
g. Use the debugger to watch your variables change
h. Use operators to work with variables
i. “if” statements make decisions
j. Loops perform an action over and over
k. Use code snippets to help write loops
l. Controls drive the mechanics of your user interfaces
m. Create a WPF app to experiment with controls
n. Add a TextBox control to your app
o. Add C# code to update the TextBlock
p. Add an event handler that only allows number input
q. Add sliders to the bottom row of the grid
r. Add C# code to make the rest of the controls work
4. Unity Lab 1: Explore C# with Unity
Welcome to your first Head First C# Unity Lab. Writing
code is a skill, and like any other skill, getting better at it
takes practice and experimentation. Unity will be a really
valuable tool for that. In this lab, you can begin practicing
what you’ve learned about C# in
#start_building_with_chash_build_somethin and
#dive_into_chash_statementscomma_classesc.
a. Unity is a powerful tool for game design
b. Download Unity Hub
c. Use Unity Hub to create a new project
d. Take control of the Unity layout
e. Your scene is a 3D environment
f. Unity games are made with GameObjects
g. Use the Move Gizmo to move your GameObjects
h. The Inspector shows your GameObject’s components
i. Add a material to your Sphere GameObject
j. Rotate your sphere
k. Get creative!
5. 3 objects…get oriented!: Making code make sense
Every program you write solves a problem.
When you’re building a program, it’s always a good idea to
start by thinking about what problem your program’s
supposed to solve. That’s why objects are really useful.
They let you structure your code based on the problem it’s
solving so that you can spend your time thinking about the
problem you need to work on rather than getting bogged
down in the mechanics of writing code. When you use
objects right—and really put some thought into how you
design them—you end up with code that’s intuitive to write,
and easy to read and change.
a. If code is useful, it gets reused
b. Some methods take parameters and return a value
c. Let’s build a program that picks some cards
d. Create your PickRandomCards console app
e. Finish your PickSomeCards method
f. Your finished CardPicker class
g. Ana’s working on her next game
h. Build a paper prototype for a classic game
i. Up next: build a WPF version of your card picking
app
j. A StackPanel is a container that stacks other controls
k. Reuse your CardPicker class in a new WPF app
l. Use a Grid and StackPanel to lay out the main
window
m. Lay out your Card Picker desktop app’s window
n. Ana can use objects to solve her problem
o. You use a class to build an object
p. When you create a new object from a class, it’s
called an instance of that class
q. A better solution for Ana… brought to you by objects
r. An instance uses fields to keep track of things
s. Thanks for the memory
t. What’s on your program’s mind
u. Sometimes code can be difficult to read
v. Use intuitive class and method names
w. Build a class to work with some guys
x. There’s an easier way to initialize objects with C#
y. Use the C# Interactive window to run C# code
6. 4 types and references: Getting the reference
What would your apps be without data? Think about it
for a minute. Without data, your programs are…well, it’s
actually hard to imagine writing code without data. You need
information from your users, and you use that to look up
or produce new information to give back to them. In fact,
almost everything you do in programming involves working
with data in one way or another. In this chapter, you’ll learn
the ins and outs of C#’s data types and references, see
how to work with data in your program, and even learn a
few more things about objects (guess what…objects are
data, too!).
a. Owen could use our help!
b. Character sheets store different types of data on
paper
c. A variable’s type determines what kind of data it can
store
d. C# has several types for storing integers
e. Let’s talk about strings
f. A literal is a value written directly into your code
g. A variable is like a data to-go cup
h. Other types come in different sizes, too
i. 10 pounds of data in a 5-pound bag
j. Casting lets you copy values that C# can’t
automatically convert to another type
k. C# does some conversion automatically
l. When you call a method, the arguments need to be
compatible with the types of the parameters
m. Let’s help Owen experiment with ability scores
n. Use the C# compiler to find the problematic line of
code
o. Use reference variables to access your objects
p. Multiple references and their side effects
q. Objects use references to talk to each other
r. Arrays hold multiple values
s. Arrays can contain reference variables
t. null means a reference points to nothing
u. Welcome to Sloppy Joe’s Budget House o’ Discount
Sandwiches!
7. Unity Lab 2: Write C# Code for Unity
Unity isn’t just a powerful, cross-platform engine and editor
for building 2D and 3D games and simulations. It’s also a
great way to get practice writing C# code. In this lab,
you’ll get more practice writing C# code for a project in
Unity.

a. C# scripts add behavior to your GameObjects


b. Add a C# script to your GameObject
c. Write C# code to rotate your sphere
d. Add a breakpoint and debug your game
e. Use the debugger to understand Time.deltaTime
f. Add a cylinder to show where the Y axis is
g. Add fields to your class for the rotation angle and
speed
h. Use Debug.DrawRay to explore how 3D vectors work
i. Run the game to see the ray in the Scene view
j. Rotate your ball around a point in the scene
k. Use Unity to take a closer look at rotation and
vectors
l. Get creative!
8. 5 encapsulation: Keep your privates…private
Ever wished for a little more privacy?
Sometimes your objects feel the same way. Just like you
don’t want anybody you don’t trust reading your journal or
paging through your bank statements, good objects don’t let
other objects go poking around their fields. In this chapter,
you’re going to learn about the power of encapsulation, a
way of programming that helps you make code that’s
flexible, easy to use, and difficult to misuse. You’ll make
your objects’ data private, and add properties to
protect how that data is accessed.

a. Let’s help Owen roll for damage


b. Create a console app to calculate damage
c. Design the XAML for a WPF version of the damage
calculator
d. The code-behind for the WPF damage calculator
e. Tabletop talk (or maybe…dice discussion?)
f. Let’s try to fix that bug
g. Use Debug.WriteLine to print diagnostic information
h. It’s easy to accidentally misuse your objects
i. Encapsulation means keeping some of the data in a
class private
j. Use encapsulation to control access to your class’s
methods and fields
k. But is the RealName field REALLY protected?
l. Private fields and methods can only be accessed
from instances of the same class
m. Why encapsulation? Think of an object as a black
box...
n. Let’s use encapsulation to improve the
SwordDamage class
o. Encapsulation keeps your data safe
p. Write a console app to test the PaintballGun class
q. Properties make encapsulation easier
r. Modify your Main method to use the Bullets property
s. Auto-implemented properties simplify your code
t. Use a private setter to create a read-only property
u. What if we want to change the magazine size?
v. Use a constructor with parameters to initialize
properties
w. Specify arguments when you use the new keyword
9. 6 inheritance: Your object’s family tree
Sometimes you DO want to be just like your parents.
Ever run across a class that almost does exactly what you
want your class to do? Found yourself thinking that if you
could just change a few things, that class would be
perfect? With inheritance, you can extend an existing
class so your new class gets all of its behavior—with the
flexibility to make changes to that behavior so you can
tailor it however you want. Inheritance is one of the most
powerful concepts and techniques in the C# language: with
it you’ll avoid duplicate code, model the real world
more closely, and end up with apps that are easier to
maintain and less prone to bugs.

a. Calculate damage for MORE weapons


b. Use a switch statement to match several candidates
c. One more thing…can we calculate damage for a
dagger? and a mace?
d. When your classes use inheritance, you only need to
write your code once
e. Build up your class model by starting general and
getting more specific
f. How would you design a zoo simulator?
g. Every subclass extends its base class
h. Use a colon to extend a base class
i. A subclass can override methods to change or
replace members it inherited
j. Some members are only implemented in a subclass
k. Use the debugger to understand how overriding
works
l. Build an app to explore virtual and override
m. A subclass can hide methods in the base class
n. Use the override and virtual keywords to inherit
behavior
o. When a base class has a constructor, your subclass
needs to call it
p. It’s time to finish the job for Owen
q. Build a beehive management system
r. The Queen class: how she manages the worker bees
s. The UI: add the XAML for the main window
t. Feedback drives your Beehive Management game
u. Some classes should never be instantiated
v. An abstract class is an intentionally incomplete class
w. Like we said, some classes should never be
instantiated
x. An abstract method doesn’t have a body
y. Abstract properties work just like abstract methods
10. Unity Lab 3: GameObject Instances
C# is an object-oriented language, and since these Head
First C# Unity Labs are all about getting practice writing
C# code, it makes sense that these labs will focus on
creating objects.

a. Let’s build a game in Unity!


b. Create a new material inside the Materials folder
c. Spawn a billiard ball at a random point in the scene
d. Use the debugger to understand Random.value
e. Turn your GameObject into a prefab
f. Create a script to control the game
g. Attach the script to the Main Camera
h. Press Play to run your code
i. Use the Inspector to work with GameObject
instances
j. Use physics to keep balls from overlapping
k. Get creative!
11. 7 interfaces, casting, and “is”: Making classes keep
their promises
Actions speak louder than words.
Sometimes you need to group your objects together based
on the things they can do rather than the classes they
inherit from. That’s where interfaces come in—they let you
work with any class that can do the job. But with great
power comes great responsibility, and any class that
implements an interface must promise to fulfill all of its
obligations…or the compiler will break its kneecaps, see?
a. The beehive is under attack!
b. We can use casting to call the DefendHive method...
c. An interface defines methods and properties that a
class must implement...
d. Get a little practice using interfaces
e. You can’t instantiate an interface, but you can
reference an interface
f. Interface references are ordinary object references
g. The RoboBee 4000 can do a worker bee’s job
without using valuable honey
h. The IWorker’s Job property is a hack
i. Use “is” to check the type of an object
j. Use “is” to access methods in a subclass
k. What if we want different animals to swim or hunt in
packs?
l. Use interfaces to work with classes that do the same
job
m. Safely navigate your class hierarchy with “is”
n. C# has another tool for safe type conversion: the
“as” keyword
o. Use upcasting and downcasting to move up and
down a class hierarchy
p. Upcasting turns your CoffeeMaker into an Appliance
q. Upcasting and downcasting work with interfaces, too
r. Downcasting turns your Appliance back into a
CoffeeMaker
s. Interfaces can inherit from other interfaces
t. Interfaces can have static members
u. Default implementations give bodies to interface
methods
v. Add a ScareAdults method with a default
implementation
w. Data binding updates WPF controls automatically
x. Modify the Beehive Management System to use data
binding
y. Polymorphism means that one object can take many
different forms
12. 8 enums and collections: Organizing your data
When it rains, it pours.
In the real world, you don’t receive your data in tiny little
bits and pieces. No, your data’s going to come at you in
loads, piles, and bunches. You’ll need some pretty
powerful tools to organize all of it, and that’s where enums
and collections come in. Enums are types that let you define
valid values to categorize your data. Collections are special
objects that store many values, letting you store, sort, and
manage all the data that your programs need to pore
through. That way, you can spend your time thinking about
writing programs to work with your data, and let the
collections worry about keeping track of it for you.

a. Strings don’t always work for storing categories of


data
b. Enums let you work with a set of valid values
c. Enums let you represent numbers with names
d. We could use an array to create a deck of cards…
e. Lists make it easy to store collections of…anything
f. Lists are more flexible than arrays
g. Let’s build an app to store shoes
h. Generic collections can store any type
i. Collection initializers are similar to object initializers
j. Let’s create a List of Ducks
k. Lists are easy, but SORTING can be tricky
l. IComparable<Duck> helps your list sort its ducks
m. Use IComparer to tell your List how to sort
n. Create an instance of your comparer object
o. Overriding a ToString method lets an object describe
itself
p. Update your foreach loops to let your Ducks and
Cards write themselves to the console
q. You can upcast an entire list using IEnumerable<T>
r. Use a Dictionary to store keys and values
s. The Dictionary functionality rundown
t. Build a program that uses a dictionary
u. And yet MORE collection types…
v. A queue is FIFO—first in, first out
w. A stack is LIFO—last in, first out
x. Downloadable exercise: Two Decks
13. Unity Lab 4: User Interfaces
In the last Unity Lab you started to build a game, using a
prefab to create GameObject instances that appear at
random points in 3D space and fly in circles. This Unity Lab
picks up where the last one left off, allowing you to apply
what you’ve learned about interfaces in C# and more.
a. Add a score that goes up when the player clicks a
ball
b. Add two different modes to your game
c. Add game mode to your game
d. Add a UI to your game
e. Set up the Text that will display the score in the UI
f. Add a button that calls a method to start the game
g. Make the Play Again button and Score Text work
h. Finish the code for the game
i. Get creative!
14. 9 LINQ and lambdas: Get control of your data
You’re ready for a whole new world of app
development.
Using WinForms to build Windows Desktop apps is a great
way to learn important C# concepts, but there’s so much
more you can do with your programs. In this chapter, you’ll
use XAML to design your Windows Store apps, you’ll learn
how to build pages to fit any device, integrate your
data into your pages with data binding, and use Visual
Studio to cut through the mystery of XAML pages by
exploring the objects created by your XAML code.

a. Jimmy’s a Captain Amazing super-fan...


b. Use LINQ to query your collections
c. LINQ works with any IEnumerable<T>
d. LINQ’s query syntax
e. LINQ works with objects
f. Use a LINQ query to finish the app for Jimmy
g. The var keyword lets C# figure out variable types for
you
h. LINQ queries aren’t run until you access their results
i. Use a group query to separate your sequence into
groups
j. Use join queries to merge data from two sequences
k. Use the new keyword to create anonymous types
l. Add a unit test project to Jimmy’s comic collection
app
m. Write your first unit test
n. Write a unit test for the GetReviews method
o. Write unit tests to handle edge cases and weird data
p. Use the => operator to create lambda expressions
q. A lambda test drive
r. Refactor a clown with lambdas
s. Use the ?: operator to make your lambdas make
choices
t. Lambda expressions and LINQ
u. LINQ queries can be written as chained LINQ
methods
v. Use the => operator to create switch expressions
w. Explore the Enumerable class
x. Create an enumerable sequence by hand
y. Use yield return to create your own sequences
Random documents with unrelated
content Scribd suggests to you:
between its upper and lower rails, always be just so far away, and
no farther, from the rails.”
It seemed to Cobb that he could advance nothing but what this
man had a ready explanation for its action or cause. It was, indeed,
a most marvelous invention. Here he was traveling at the rate of two
hundred and forty miles per hour, and scarcely felt the motion.
“Where is the electricity for these powerful engines generated?”
he inquired.
“For the Central and Northern, as well as for the Pacific Pneumatic
and Mountain lines, the dynamos are at the Shoshone Falls, in
Idaho. These falls furnish an immense water-power, estimated at
over 300,000 horse-power. The current is delivered at the station in
great cables of peculiar construction, and well insulated.”
“Do you have any accidents on the roads? At such a rate of speed,
an accident would be fraught with frightful consequences,” Cobb
continued.
Rawolle smiled as he said:
“During your time, accidents were not uncommon—in fact, I might
say quite common, judging from the old chronicles; but we have
never had an accident yet upon any of our lines. There have been,
of course, breaks and delays; but as each train is in communication
with each other, and with each end, and with the chief of the
exhausting department, everything is known at all times regarding
the position of trains and their condition.”
Striking a match, he continued:
“No train could run into the one ahead of it, for the reason that
there will always be a cushion of air between them; and further,
were any ordinary number of runners to break at one time, the train
would not be affected by the loss.”
“How wonderful, yet how simple!” exclaimed Cobb, lost in
admiration. “But I am at a loss to understand why the people of my
time did not discover and put into operation the same project.”
“Perhaps someone did discover the principle, but had not the
means to test his theory,” Rawolle returned.
“How long has this system been in operation?”
“About thirty years,” he replied, after a moment’s thought.
“Tell me one other thing,” said Cobb; “has the pneumatic railroad
superseded all other kinds?”
“Oh, no; by no means. There are railroads all over the United
States, and very much the same style of your day, excepting the
great improvements which have been made, and also the one other
most important fact, that all engines are run by electricity. The
pneumatic lines are through lines only, and are for rapid transit
between very distant points, and only for passengers, mail, and
express. All freight is sent by the other roads.”
“Then, the towns, excepting the great centers, are connected by
electric railroads for inter-transportation?”
“Yes; the pneumatic is only an auxiliary to the rest of the roads—a
means only of overcoming great distances quickly.”
“And what is considered good speed for the electric roads?”
“Seventy-five miles per hour for passenger trains, and fifty for
freights.”
“Then, they must be very differently constructed from those of
old,” exclaimed Cobb.
“They have very different roadbeds, and, of course, different
engines. But enough for the present,” looking at his watch. “It is 18
dial, and we had better get into the sleeper and prepare for supper,
for we are almost at Salt Lake.”
CHAPTER X

After supper, and when settled back once again in the cushions of
their sleeper, Cobb immediately resumed the conversation about the
pneumatic roads.
“They must be very rich and powerful corporations, these which
own such lines as this?”
“No,” returned Rawolle; “for they are not owned by individuals,
but by the government. All railroads in the United States are in the
hands of the government, and are operated with a view to just
covering expenses.”
“Are the rates of passage high?”
“We do not consider them so. There is one fixed rate throughout
the country of one cent per mile.”
“But,” musingly inquired Cobb, “is not there a difference in
operating the roads? Are not some more expensive to the
government than others?”
“Certainly,” answered Rawolle. “But, like postage on letters, a
universal rate is found to be the best; the larger and more
patronized roads paying the losses incurred by the smaller and
country routes.”
“I presume,” said Cobb, “that there can be but few changes in the
general management, supervision, etc., of the roads from those in
vogue in my time?”
“There you make a mistake,” quickly returned the other; “for,
having been connected with the pneumatic lines, I am well posted in
what is done to-day and what was the manner of operating railroads
during the first part of the twentieth century. Nearly every detail of
to-day’s management differs from that in vogue a hundred years
ago. It would tire you for me to go into details. A few facts, though,
I will give you: All freight is of two classes, and is sent at so much
per pound per mile. At the sending point it is stamped similarly to a
letter, showing date, place of shipment, destination, etc. The same
rule is followed in regard to baggage of individuals, the owner
having a duplicate of the stamp placed upon his baggage. There are
no tickets shown or taken up on the pneumatic lines, but the names
of passengers to depart from the train at intermediate points are
telegraphed ahead, and the persons are looked after by the
inspectors. On all lines the tracks are double, trains passing but one
way on each line of rail. There are no whistles or bells to the
locomotives of the service lines; no tender with its coal and water;
no cab in the rear for the engineer; no furnace and fireman. The
locomotive is an electric one, with the engineer in a cab in front. In
place of the huge boilers is an iron and steel tank containing the
storage batteries. The whole weight is nearer the rail, thus bringing
down the center of gravity and reducing the danger from oscillation.”
As Rawolle was thus enlightening Cobb about the innovations
made in the last century, the sleeper door opened, and a trainman
entered and walked direct to their section and asked for Mr. Rawolle,
saying he had a telegram for him, at the same time handing out the
envelope.
Rawolle took it and thanked the man, who then left the car.
“He hit the right man squarely that time!” surprisedly exclaimed
Cobb. “They seem to know you here.”
“Not at all,” replied Rawolle, smiling, while he tore open the
envelope. “Every person on the train is known by name, and section,
and car. Such is the system.”
He opened and read the telegram.
“There!” he exclaimed, after a moment, extending the telegram to
Cobb. “There is an order from the Secretary of State to stop at the
Central Sea.” And he and Lyman looked quizzingly at their
companion, as he slowly took the telegram and read:

“Washington, 16, 18 D.
“Albert Rawolle, on Central Pneumatic No. 3, east:
“Telegram received. Stop at Cairo. Submarine boat Tracer ordered
there to take you and Cobb through Central Sea.
“By order Secretary State.
“Harry G. Collins, Chief Clerk.”

Cobb read it through twice ere he ventured any remark; then,


handing it back while a troubled look overspread his countenance,
he said:
“Cairo is in Illinois, at the junction of the Ohio with the Mississippi;
but I fail to comprehend the import of the words ‘Central Sea.’ The
submarine boat spoken of does not surprise me, for I would
naturally expect that that which was almost an accomplished fact in
1887, would be an actual success at this late date.”
“There is no Ohio River, or not as was in your time. The Ohio is
now but a small stream flowing into the Central Sea,” replied
Rawolle.
“Again those words ‘Central Sea;’ what does it mean? Is there an
inland sea?” and Cobb looked inquiringly at both of the others.
“There is,” slowly spoke Rawolle.
“And a mighty big one, too,” put in Lyman.
Cobb was highly educated and of a sanguine temperament; he
neither doubted what seemed impossible, nor did he believe until
the facts were clearly before his mind. He was perfectly cognizant of
the physical geography of the United States, and did not understand
under what conditions a great inland sea could have been formed, or
maintained.
Settling himself back in his seat and breaking the circuit of the
electric light to lessen the glare in their faces, Rawolle continued:
“I will give you some facts concerning this sea, for, now that you
are one of a new generation, you have much to learn, and we
cannot pass the hours between now and bed-time to better
advantage. On the last day of August, 1916,” he began, “at about 14
dial, or as they then said, 2 P. M., that which was taken, at the time,
as the shock of a great earthquake, was felt by thousands of
persons throughout the central portion of the United States. In less
than two hours later, the nation was informed of the true nature of
the shocks which followed each other in rapid succession. It was the
explosion of natural gases deep down in the strata of the earth’s
crust, and the scene of the disturbances covered a vast area of
territory. During the following week the shaking and trembling of the
earth caused great destruction in many cities and towns not
otherwise affected. Houses fell, the water supply failed, and other
serious results were experienced. But throughout portions of the
area now covered by the Central Sea, the scene was terrible, awe-
inspiring, horrible. The earth heaved and sank; huge cracks opened,
and flames hundreds of feet high shot into the air; thunder and
lightning added to the horrors of the situation. The bursting of the
earth’s crust was attended by an appalling roar and crash, as if a
million peals of thunder had combined in one grand effort to terrify
mankind; then came a pall of dense, black smoke that wrapped the
land in darkness. Consternation seized upon the people, and well it
might, for when the full import of the disturbances was known, it
was only then ascertained that a great cataclysm had befallen the
nation. Without going too much into details, for you can later on
gain a full knowledge of this great physical disturbance from the
books published soon after its occurrence, I will explain but a few of
the facts causing it. You are aware, Mr. Cobb, to what extent natural
gas was used in the United States in 1887; that there were
thousands of wells pouring out millions of cubic feet daily; that many
of them showed pressure of from ten to twenty atmospheres. From
the time you left the world, as it were, until August, 1916, gas wells
were being sunk all over the country drained by the Ohio and its
tributaries. Their number was way up in the thousands. Billions of
cubic feet of natural gas were being consumed or flowing to waste
daily. Pittsburgh alone used 300,000,000 cubic feet a day in its vast
manufactories. The earth in the Ohio basin was honey-combed with
the gas pockets and strata, and gas veins were struck in which the
gas was under such pressure that the flow could not be checked by
human hands. It was 14 dial, as I have said, on the last day of
August, 1916, and the workmen in the large foundry of Dillenback &
Co., at Lakeside, on the Ohio, some fifty miles below Pittsburgh,
were tapping a huge melting of aluminum bronze for the purpose of
casting the outer shell of one of the latest model guns of that
period. But let me first describe the interior arrangements of the
foundry, that you may fully grasp the situation as it then stood, and
the cause of the results which followed. Natural gas was, and had
been for a long time, the fuel used in these works. Up to 1914 the
gas boring of Lakeside had furnished all the gas required. This well
was of ten-inch bore, and reached a depth of 4,737 feet, but in the
year mentioned the well had failed to furnish gas at any pressure.
The standard pipe had been moved and an iron plate set over the
mouth of the tube, on a level with the floor. Five hundred feet from
this well a boring to 4,016 feet had struck a new stratum, giving vast
quantities of gas at a pressure of five atmospheres. To revert back:
Just as the tapping of the furnaces was made, the steam boiler of
the crane engine, through some unaccountable cause, burst. The
concussion shook the buildings, tore up the ground, displaced the
iron plate over the disused gas well, and broke the aluminum
furnaces, letting over one hundred tons of molten metal flow rapidly
across the foundry floor. Recovering from the first shock and fright of
the explosion, all efforts were at once made to arrest the flow of the
liquid stream, or to divert its course away from the old well. That
well, as all knew, still contained gas intermingled with common air,
the mixture being of a very explosive nature. All perceived at a
glance what would be the consequences if such a mass of molten
metal should precipitate itself into the old well and fall over 4,500
feet into the interior of the earth’s crust; the shock at bottom, the
continuance of heat, the explosive medium through which it would
pass, all were dangers to be dreaded. The gas strata were overlaid
and underlaid by water and air strata; the breaking of one into
another would cause a commingling of their constituent parts, and
form explosive compounds of the most dangerous types. Human
efforts failed to stem the fiery stream in its onward course across the
foundry floor. With a bounding, hissing, and, as it were, victorious
cry, the river of melted aluminum approached, reached and went
plunging down into the old supply-pipe. Who could describe the
terrible effect! Of all those hundreds of human beings employed in
Dillenback’s works, but two lived to tell the story of the catastrophe.
These two men knew only one thing: that the earth seemed to
shake to its very center, and they were hurled down among the
debris of the fallen buildings, while sheets of fire almost scorched
their very souls. Peal upon peal of thunder reverberated about them,
and then darkness buried everything from their vision. Burned,
bleeding, and nearly dead, these two men found themselves pinned
down by the timbers of the works. Fire was upon every side; the
timbers were burning, the heat was oppressive, and from a horrible
death no man could save them. There was a higher Power, though,
who had ordained that these two men should be witnesses of the
full effects of this mighty effort of nature to overcome the grasping
endeavors of man to accumulate wealth at the expense of reason. A
sudden rush of waters from beneath them cooled their parching
bodies, extinguished the fires about them, raised the mass of
timbers which pinned them down, and gave them their liberty. You
can read of this escape, as it is fully chronicled. This was the cause;
now the effects. Are you tired?” seeing Cobb so quiet; “or would you
like a drink of something to warm the inner man?”
Cobb had sat with scarcely a movement, save the heaving of his
chest, as he listened to this terrible narrative. The last words of
Rawolle seemed to awaken him.
“No, and yes,” he slowly replied. “Let us take a glass of wine and
retire. I wish to think this over before you finish. My head aches, and
I need rest.”
A few minutes later, all was quiet in the first sleeper of the Central
Pneumatic No. 3, east.
It was 2:25 dial, or 25 minutes past 2, the next morning, when
the Central Pneumatic arrived at Cairo.
Here Rawolle’s party was met at the train by an officer from the
government submarine boat Tracer, and conducted aboard that
vessel, which lay at anchor in the stream. Cobb was informed that,
as it was so early, he had better retire and take a little more rest, for
they would not weigh anchor until 7 dial. Acquiescing, he was shown
to his state-room.
It was a cozy affair, indeed, that Cobb was ushered into—a little,
but handsomely furnished room, containing all that one could desire
in a thoroughly well-appointed apartment. Electric lamps threw a
charming, subdued light over everything in the room, while an
electric heater diffused a gentle warmth which was most agreeable
this September morning. Retiring to rest, Cobb dreamed of nothing
but pneumatic railways, submarine boats, and gigantic convulsions
of nature.
It was about 7 dial when both Rawolle and Lyman came and
awoke their guest, who, after a refreshing bath and a delicious
breakfast, ascended to the upper deck of the Tracer.
The main deck of the vessel was of very small area amidship,
some two feet above the water-line, and inclosed by an iron railing.
A beautiful scene presented itself to his view. The Tracer lay about
half a mile from the docks of Cairo, and that city was just awakening
to its daily round of bustle and activity. The stream was covered with
shipping, some at anchor, while others were plying between the city
and the opposite shore, a mile and a half away. Sailing craft there
were a plenty, but no steamers, though there were many vessels
moving swiftly through the water, yet showing no smoke or funnels.
This fact was immediately noted by Cobb, and inquiry made of
Lyman, who stood near him, as to why there was no smoke visible.
“Neither coal nor wood is now used for marine propulsion,” replied
Lyman. “Lipthalite vapor, or lipthalene, is now the motive power of
vessels without sails. I will show you some of this lipthalite, later on,
in this vessel.”
Turning his eyes from the busy and charming scene about him,
Cobb’s thoughts came back to his immediate surroundings. What
was he standing upon? The small, water-flush deck of a metal
submarine vessel, the total area of which could not exceed a
thousand square feet. A number of peculiar openings, valves, and
pipes abutted on the deck, and a single metal mast stood at the
bows; but no smoke-stack or other accessories to propulsion were
visible.
Surveying all these things, he was about to ask information
concerning their use, when Lieutenant Sibley, the officer in
command, made his appearance, and was introduced to him.
“I am sorry I was not aboard to welcome your arrival, last
evening, Mr. Cobb,” he began, in a courteous and pleasing tone of
voice, “but I was detained in Central City, across the river, until early
this morning. I hope you slept well, and are ready for the trip to
Pittsburgh?”
“Not only ready, but anxious for it,” was the reply.
In a few moments more, by order of the Lieutenant, the anchor
was raised, and the Tracer moved up the stream, headed E. ¼ N.
As the vessel moved through the shipping, the national colors,
which were displayed from its mast, were saluted by the dipping of
flags and sounding of whistles.
A hoarse-toned marine whistle, almost at Cobb’s feet, answered
these salutations, and also caused that gentleman to jump back with
a startled expression.
Drawing his hand from the whistle button, Lieutenant Sibley
apologized for frightening him, saying:
“It did not occur to me that I had others aboard than those who
are accustomed to these vessels.”
The Tracer was a cigar-shaped vessel of two hundred feet in
length by twenty beam, or middle diameter, and of nearly 1,000 tons
displacement when submerged.
With an outer shell of aluminum bronze and an inner shell of the
finest steel, the vessel combined great strength with a minimum
amount of metal in its construction.
“Gentlemen, if you will follow me,” said Lieutenant Sibley, “I will
show you over the vessel.”
Descending the companion-way, the entrance to which could be
closed by an air-tight door, the party proceeded about the vessel.
Longitudinally and horizontally, from apex to apex of the cones,
was a steel deck dividing the vessel into two equal parts. The first
forty-five feet of each cone contained the tubes of compressed air
and oxygen. There were in each end about 2,500 feet of five-inch
steel tubes, one-half inch thick, containing over 4,500 cubic feet of
air under a pressure of 1,500 pounds per square inch. This was
sufficient, as Lieutenant Sibley explained, to sustain active life for
the entire crew for two hours. “But we have other facilities,”
continued the Lieutenant, “by which the vitiated air is deprived of its
carbonic acid, and then recharged with the lipthalene gas from the
receivers and oxygen from the pipes, giving about eight hours of
active life to the inmates of the vessel when totally deprived of air
externally.”
The store-rooms, mess-rooms, and quarters of the men were
visited. Small though these rooms were, they were made with every
convenience, and given every useful contrivance which this great
age of invention could produce.
The Tracer was not a war vessel, but belonged to the
Geographical Bureau, and was used in charting the Central Sea. Her
complement was small: two engineers, two pilots, one electrician,
cook, assistant cook, captain’s boy, two helpers, and two officers.
Everything was so admirably arranged, and machinery played such a
wonderful part in the power required to handle the vessel, that a
larger force was not only unnecessary, but would have been
detrimental to a satisfactory working of the vessel.
Cobb called attention to the steel partitions between the rooms,
and asked why so much strength was required.
“There are,” answered Lieutenant Sibley, “twelve partitions,
dividing the vessel into twenty-six compartments. In case of accident
to the outer shell, whereby water might gain ingress, that particular
compartment can instantly be closed and the flow of water confined
to it. Before going down into the engine-room, I will give you some
idea of this remarkable vessel. The Tracer, when fully submerged,
displaces 1,000 tons of water. The shell of the vessel is of 1½-inch
steel, covered externally by an aluminum armor of .3 of an inch in
thickness, and weighs 570,000 pounds. The steel deck upon which
we stand weighs 500,000; the steel partitions, braces, and iron-work
weigh 195,000; the engines and machinery, 200,000; compressed
air pipes, 125,000; the water cylinders, which you will soon see,
weigh 100,000; all other parts, stores, lipthalite, etc., are allowed
50,000 pounds. Now, added to all this, is an immense aluminum-
covered iron weight of 150,000 pounds attached to the bottom of
the vessel, and which can instantly be freed and dropped from the
ship into the sea, by simply breaking an electrical connection. This
circuit is accessible from all parts of the vessel. Let us descend into
the engine-rooms, and I will there explain why I have been so
particular in giving you these weights.”
Following the Lieutenant down the narrow ladder into the depth
below, Cobb, Rawolle, and Lyman were soon facing the powerful but
small engines of the Tracer.
The room was large, clean, warm, and brightly illuminated by
electricity. Here, Mr. Lochridge, the first engineer, was introduced by
Lieutenant Sibley.
Cobb had seen the engines of many of the first-class vessels of his
day, had noted their power and huge dimensions; but never before
had he perceived such beautiful specimens of strength combined
with size; nor did the finest workmanship he had ever seen approach
to the perfection of the engines he saw beating and pulsating before
him.
Cobb looked them carefully over before venturing any remark. He
noted an absence of steam and heat, the peculiar construction of
the boilers, and many other, to him, new inventions.
“I believe, Mr. Rawolle,” he finally said, turning to him, “that you
informed me last evening that no steam was used at the present
day, but in its place, lipthalite?”
“That is our fuel and vapor nowadays,” broke in Mr. Lochridge.
He led the way to two receivers, bearing some slight resemblance
to the boilers of a steamer.
“Here are our boilers and furnaces combined,” he continued; “and
these,” as he laid his hand upon two very peculiarly constructed
frontal additions, which had quite a number of straight pipes running
into the large receiver, “are our furnaces, if you choose to call them
by such a designation; we call them generators. Lipthalite is our fuel
and gas developer.”
Mr. Lochridge stooped down and took from a case, containing
many more, a stick of dark-brown material about four feet long by
one inch in diameter, and handed it to Cobb for his inspection,
saying:
“That is lipthalite. These rods are placed in those tubes, and, by
proper mechanism, pushed through into the field of an arc light
situated in the generator. Gas is evolved in great quantities, but the
composition burns only while in the field of the arc. Little heat is
developed. The gas is delivered to the cylinders in the same manner
as was steam in your day.”
“What is the volume of gas as compared with the solid base? and
is it cheaper and as efficient as vapor of water?”
“I expected that question, Mr. Cobb,” returned Mr. Lochridge, “and
will explain it. One cubic foot of water, as you know, produces nearly
1,700 cubic feet of steam; one cubic inch of gunpowder makes
about 1,500 cubic inches of carbonic acid and nitrogen gases; while
one cubic inch of lipthalite will evolve 500 cubic feet of lipthalene, a
combination of nitrogen, carbonic acid, and other gases. The ratio
between water and lipthalite, evolved into gas, is as 1 to 500. In
other words, to operate the engines of this vessel at a given speed
for one hour, requires, of coal and water, one and thirty-one tons
respectively; while of lipthalite, twenty-three pounds. Leaving out
the question of water, of which there is a plentiful supply
surrounding the vessel, the gain in a twenty-four hours’ run for
lipthalite over coal is as 1 is to 96; or one ton of lipthalite is used
where ninety-six tons of coal would have been required.”
“It is a wonderful discovery!” exclaimed Cobb, and a far-away,
dreamy expression came into his eyes. For an instant his mind went
back to the days, long years ago, when he had spent hours in his
laboratory, at the Presidio, searching for this very same agent—the
storage of great power in small volume—and his partial success in
the discovery of meteorite. Then his thoughts led him to the
remembrance that his new explosive had been sent to Washington.
What had become of it? Lost, lost, years ago!
“Do you comprehend the advance in science that has been made
in a hundred years?” and Rawolle broke his reverie by gently
touching him on the arm.
“Can I help it? Could anyone have dreamed of such a power as
this?”
Yes. He had dreamed of it; and many, many times. But too
modest to venture the knowledge that his thoughts and work had
been centered on such a grand invention, he turned to Mr.
Lochridge, and abruptly asked:
“Is lipthalite turned into gas by explosion?”
“By no means,” quickly returned that gentleman; “by
inflammation, and inflammation alone, and not very fast, either. In
our generators, here, it is at the rate of about two hundred and fifty
feet of these sticks per hour.”
“Strange that I should have worked on this very principle!” he
said, half aloud; then turning to Lieutenant Sibley, he exclaimed:
“You spoke of water cylinders; where are they?”
“Under the grating, Mr. Cobb.”
Mr. Lochridge raised the grated flooring, and showed three iron
cylinders, each divided into halves, with piston-rods and cylinder-
heads. They were about four feet in diameter by twenty-three feet
long.
“These, gentlemen,” he continued, “are connected by pipes with
the outside of the vessel. Water can be admitted into any one or all
of these cylinders, and, in two minutes, driven out by the pistons.
Should these pistons fail, from any cause, to work, pumps connected
with the cylinders could perform the same duty in ten minutes. I
gave you the weights a few minutes ago; what did I make them?”
taking a piece of paper and pencil from his pocket, and making a
few notes. “Yes; 1,940,000 pounds, or just thirty tons less than our
displacement. The water cylinders have a capacity of fifty tons. By
allowing thirty tons of water to enter the cylinders, our weight is
equal to our displacement, and we sink. Allowing all loss of weight
aboard ship during a cruise, and which never exceeds twenty tons,
we can always decrease our buoyancy and sink to the bottom, if
necessary. Now, here,” pointing to the left, and along the walls of
the vessel, “are the dynamos for the electric lights, fans for
circulating the fresh air, steering apparatus, electric heaters, exhaust
pumps for expelling the vitiated air and drawing in the fresh, and
many other inventions, the uses of which you can learn at your
leisure.”
The engine-room of the Tracer was indeed a curiosity-shop to
Junius Cobb. Pipes in every direction; electric wires crossed and
recrossed one another; peculiar machines occupied each side of the
room, and a hundred other things, strange to him, were upon either
side. Leaving the engine-room, Lieutenant Sibley led the way to the
instrument-room of the ship. Here a new treat awaited Cobb.
Situated just at the junction of the main shell and the forward
cone, was the pilot’s, or instrument, room. In an easy-chair, in front
of a box about two feet square, and resting on the table, sat Mr.
Irwin, the first pilot of the Tracer. On either side of him, and fastened
to the walls of the room, were a great number of delicate
instruments, some of which were familiar to Cobb. At either side of
the box on the table were several rows of push-buttons; to the left,
a fine compass, and to the right, speaking tubes and bells.
“You met Mr. Cobb at breakfast, did you not, Irwin?” questioned
Lieutenant Sibley, as the pilot arose and greeted the entrance of the
party with a smile.
“Yes, I had that pleasure,” he returned, bowing. “Have you been
over the ship?” to Cobb.
“We have taken it all in, Mr. Irwin,” said Lyman, answering for the
party.
“How is the course? and where are we now?” asked the
Lieutenant.
“It is now 9:35, and we are headed northeast by east. Cairo is to
our rear ninety-five miles. We are over Princeton, thirty miles north
of Evansville,” was the reply.
“You may make Louisville. What time will we get there?”
Consulting his chart a moment, Mr. Irwin replied:
“Louisville is on our course now, and distant one hundred and
eighty-eight miles. We will make it at 14:12.”
“Now, Irwin, I wish you would explain the mysteries of your castle
to Mr. Cobb, and then bring the gentleman to my cabin. You will
excuse us a few minutes, will you not, Mr. Cobb? I have some official
papers for Mr. Rawolle’s inspection. Mr. Lyman, will you come along,
too?” to that gentleman.
As they left the room, Mr. Irwin turned to Cobb, and held a few
minutes’ conversation regarding the remarkable experience of the
latter; then, rising, he pointed to the right wall and said:
“These are instruments used aboard submarine vessels of to-day.
There is a thermometer for interior temperature, that for exterior
temperature; here are electric dials giving the humidity in various
parts of the ship. These dials to the left show the motion of the fans,
dynamos, and all other moving machinery aboard. The interior
pressure is here noted,” placing his hand upon a barometer, “and the
exterior, there. The purity of the air is indicated by this little delicate
meter. The speed of the vessel is shown on that reel, which is
connected, electrically, with the log. These little bells,” pointing to
twenty-four little bells overhead, “will quickly give warning of the
entrance of water into any of the chambers. The equilibrium of the
ship is denoted automatically by this alcohol cross combined with a
double pendulum. The lipthalene pressure is given here. The many
buttons and tubes communicate to all parts of the ship. Those two
buttons release the iron weight at the bottom of the vessel, and
these twelve buttons regulate the entry and exit of the water in the
six water cylinders. The speed is regulated here, and the vessel
steered by this little wheel;” and he pointed out the various
instruments as he mentioned their uses. Cobb carefully examined
every instrument as it was mentioned to him. Turning to Mr. Irwin,
he asked:
“But where is your steersman—your lookout, I mean? Cooped up
in this little room, you can see nothing around the ship. Even on
deck, especially in rough weather, you would be too low down to
have much of a view of your surroundings.”
“The explanation is most simple. Look into that box, if you please,
and let your head fill the opening, to darken the interior.”
He smiled as he noted Cobb’s perplexed expression.
Obeying Mr. Irwin’s request, Cobb fitted his face to the opening
and gazed inside the box. He saw the sea rising and falling in its
swell, vessels passing in various directions, the faint blue outlines of
the shore to the northwest, and—click, the scene changes: now
other vessels in view, and a clear circle of the horizon, denoting a
great expanse of water. Again a clicking sound, and—
“My God!” he cried, starting back; “a ship! a ship is almost upon
us!”
Like lightning, Irwin sprang to the camera and glanced in; then
quickly reaching out his hand, his fingers touched a button, and the
hoarse marine whistle of the Tracer thundered forth its warning;
seizing the tiller-wheel, he threw it hard aport, and then, without
pausing, pressed another button, and the large gongs of the ship
pealed out their summons to its crew that danger was imminent.
Even as the alarm sounded, came a shock, a shiver, a slight
careening of the vessel, and as Irwin took his white face from the
camera, the grateful exclamation:
“Thank God! we are safe! Look! the monster passes by!”
Into the camera Cobb again peered; the dark, black stern of a
large freighter was passing to the southwest.
Lieutenant Sibley and the crew of the Tracer were quickly huddled
at the door of the pilot’s room.
“Lieutenant,” said Irwin, with a salute, “I confess that we have had
a very narrow escape from being run down by a heavy freighter.
Explaining these instruments to Mr. Cobb, I failed to note the
approach of the vessel.”
The alarm having subsided, the subject was fully discussed, and
Mr. Irwin was exonerated by the Lieutenant. All parties then returned
to their various occupations.
Mr. Irwin then turned to Cobb and said:
“It was very negligent of me not to carefully survey the field for
approaching vessels. The Tracer carries but a single mast, and sits
so low in the water, that these many merchant ships, with their
sleepy crews, often fail to sight her until too late to make a proper
clearing.” Then returning to the subject upon which they had been
speaking when Cobb’s excited exclamation had burst forth, he
continued:
“I see that you have understood the object of the little dark box
on the table. It is a camera-obscura. The single mast of the Tracer is
of aluminum, strong, slight, and hollow, and rises to a height of
twenty-eight feet. A lens at the top revolves by pushing this button;
thus a perfect image of the surrounding water and all upon it is
thrown on the white ground within the box. Sitting here and looking
in the box, I note the proximity of objects and steer the vessel. The
mast also serves to carry an arc light for night traveling, and our flag
by day. Further, our air is drawn down through pipes in its interior;
for, during heavy seas, we must have the air inlets far above the
deck, which is constantly washed by the rollers.”
Some further conversation was indulged in, and then Cobb
thanked Mr. Irwin for his kindness, excused himself, and was soon
seated, with Lieutenant Sibley, in the latter’s cozy cabin.
Lunch having been disposed of, Rawolle, taking out his watch,
remarked to Cobb: “In a few minutes we will be directly over
Louisville, Kentucky; and in these few minutes, I will briefly explain
the effects of the great cataclysm of 1916, as I promised to do: The
gas strata of the Ohio basin,” he began, “extending from above
Pittsburgh to the Mississippi River, with pockets innumerable and
ramifications in every direction, contained millions of millions of
cubic feet of gas under varying pressures from nil to many
atmospheres. The catastrophe at Dillenback’s ignited the gas in what
appeared to have been the main strata. Explosion followed explosion
throughout the region now occupied by the Central Sea. The earth
was rent and broken, and the great vacuums, caused by the
annihilation of the gases, took away the support of the upper crust,
and then atmospheric pressure completed the ruin. The earth sank
and crushed into these voids until a new foundation was reached. In
some sections the fall of the crust was frightful, terrific. In the
vicinity of Cincinnati but one shock was felt, but that shock was
terrible, horrible, annihilating. The earth sank 196 feet at one fall.
Not a living soul escaped the shock of impact upon the underlying
strata. The city was an inconceivable mass of ruins, and in two days,
was covered with water. So it was over a region of 100,000 square
miles, the earth sinking everywhere, but to different depths and with
different rates of depression. Pittsburgh sank 377 feet, but so slowly
that few lives were lost, though the destruction of property was very
great. At the mouth of the Ohio the earth sank only one foot,
increasing toward the east. Millions of lives were sacrificed and
untold wealth lost, for the great depression commenced immediately
to fill with the waters from the streams flowing into the Ohio basin,
and from the underlying strata. Even the Mississippi turned its
waters into the old mouth of the Ohio and flowed east, leaving but a
small, shallow stream to flow in its old bed until augmented by the
streams and rivers emptying into it below Cairo. Even with all these
waters it was an insignificant river until it reached the Arkansas and
received the mass of water from that river. But in 1918 the river was
diverted back to its proper channel; though later on the dam was
removed, owing to the rise in the Central Sea, and the natural outlet
being at Cairo. This, in brief, Mr. Cobb, is the effect of a single
accident in a gun factory, in 1916; though who can tell but that it
might have occurred later on from some other cause?”
“But did not those who were not injured by the shocks and falling
buildings have time to move their effects before the waters overtook
them? for, surely, this immense sea did not fill up in a few days,”
ventured Cobb.
“Along the Ohio, from this side of Louisville to above Cincinnati,
scarcely any property was saved. The depression was such that the
submergence came very quickly. But this was not the case in the
surrounding country. In one week the shocks were over and the
earth quiet. People recovered from their fears a little, and looked
about them. Later on they commenced to rebuild, and it was not
until a year after that they found a new foe against which they could
not combat: the country was below the level of any outlet, natural or
artificial, and was filling up into an inland sea. Surveys were made,
and in 1918 the true condition of the country ascertained. Then, and
only then, was it found that the region now covered by the Central
Sea was destined to be lost to mankind. Human ingenuity could not
solve the problem of drainage. There was no drainage. Far below the
bed of the Mississippi, the only possible outlet, the country was
doomed to inundation. The survey was completed and the true limits
established. All within that area began to be abandoned. Property,
wherever possible, was removed; but the buildings, at least those
which could not be taken apart and moved, still remain under the
sea as monuments of a once densely populated area. To be sure,
the removal was not rapid. The exact time was known, from the
surveys made, when the waters would gain their maximum height,
or reach to any particular point.”
“Such an immense basin must have required a considerable time
to fill up?” inquired Cobb.
“It did—years. It was a gala day at Cairo, and a day of rejoicing
throughout the land, when, on the 14th of August, 1939, the Central
Sea reached the dam at that city, and passed over in a gently
increasing stream. The dam was removed, the channel opened, and
navigation from the ocean to this immense body of water, through
the mouth of the old Ohio River, was unobstructed.”
“Why,” exclaimed Cobb, in astonishment, “that was twenty-three
years after the disturbances! It took longer to fill up than I had
imagined.”
“The area lost,” continued Rawolle, “was about one hundred
thousand square miles; the volume nearly one hundred and seventy-
five trillion cubic feet. The water-shed of the Ohio produced ten
billion cubic feet per day, all of which flowed into the Central Sea.
The first two years the Mississippi discharged a like amount into the
sunken area. It was estimated that over ninety trillion cubic feet of
water were pushed up, so to speak, from the strata of the earth by
the subsidence of the upper crust. Thus, one hundred trillion cubic
feet of water rushed into the doomed basin of the Ohio in the first
two years, making inundation very rapid during that time, and
frightfully rapid during the first week. The Ohio water-shed supplied
nearly four trillion cubic feet per year, which, to complete the
seventy-five trillion necessary to fill the sea, took twenty-one years.”
“This is a most wonderful occurrence, and did I not have ocular
proof of its reality, I admit I should be loath to believe it a
possibility;” and Cobb seemed lost in a reverie of the marvelous
events which had transpired during his long sleep on Mt. Olympus.
The tinkling of a bell caused Lieutenant Sibley, who had been
writing at his desk, to look up and say:
“I presume we are near Louisville.”
Then, going to the tube, he answered Mr. Irwin, in the pilot-room,
and was informed that the vessel was then over the city of Louisville.
The Tracer was soon brought to a rest, and Cobb witnessed the
peculiar arrangements made for descending to the bottom of the
sea. He watched every movement and noted every detail, and saw
with what wonderful facility a thousand-ton ship could be made to
obey a man’s will.
The mast of the Tracer was dropped until its top rested upon the
deck of the vessel, its top closing automatically to prevent the
ingress of water. A large circular float containing air-valves, and
attached to a long hose, was loosened from its fastenings on the
deck. The water cylinders were opened, and as they partially filled,
the vessel lost its superiority of displacement and began to sink; the
large float, with its air-valves, and attached to the hose, remained
upon the top of the water, permitting air to be drawn down into the
vessel by suction. Thus a constant supply of fresh air was obtained
without recourse to the compressed air in store. In fact, the latter
was never used except in emergencies or when it was desired, as in
the case of war, to keep the approach of the vessel a secret.
The sensation of falling was apparent, but it was indescribably
peculiar; neither pleasing, nor yet distasteful—such a feeling as
when, in his boyhood days, he had sat upon the board of a swing
and let the “old cat die.”
Passing with Lieutenant Sibley and the others into the pilot’s room,
he saw the ease with which the descent was regulated, and noted
the instrument showing the depth of submersion.
Mr. Irwin pressed a button, and Cobb felt the tremor of a forward
movement. The displacement being but a trifle less than the weight
of the vessel, the movements of the ship were now regulated by its
engines and double rudders.
Stepping to the side of the room, the Lieutenant threw open the
steel covering of a bull’s-eye, and then pressed the button near it. A
brilliant flash shot out, and the rays penetrated the water for a
considerable distance in every direction.
“There!” cried Lieutenant Sibley, with an involuntary wave of his
hand. “Behold the city of the dead, Louisville!—Louisville, once such
a grand city, now a silent, slime-covered, submerged testimony of
nature’s conquering power over man’s puny will.”
Cobb pressed his face against the glass and silently gazed upon
the lifeless buildings and streets of the city. Even as they stood years
ago, so stood many at that moment. Others were in ruins, with
gaping walls and broken doors and windows, and all were covered
with mud and slime and marine vegetation.
The streets were half-way up to the second stories, but the tops of
the street-lamps could be discerned sticking out of the muddy
sediment which had been deposited over everything.
Slowly the Tracer moved forward, and the whole expanse of the
southeast side of this unfortunate, but once brilliant, city was
presented to view.
What emotions filled that man’s breast, with his eyes glued, as if
fascinated by some unknown power, upon the spot he had, in years
long since past, visited, looked upon, and walked in! With a
sickening feeling of utter sadness at his heart, he turned away.
“God’s ways are inscrutable,” he sighed. A tear glistened in his eye
as he cried: “No more! Let us ascend!”
At 24 dial the Tracer was at her moorings in Pittsburgh, and Cobb,
Rawolle, and Lyman took the Chicago Pneumatic for Washington.
As he lay in his berth in the sleeper, his mind reverted back to the
days when he had met his friends in social evenings of pleasure; to
his old friend in Duke’s Lane, and to the bright, lovely face of that
man’s daughter. Ah! how he longed for but an hour with them—an
hour of true friendship and love; how he craved to listen to but a
moment’s innocent prattle of his girl-love. Alone among strangers,
among a people far ahead of his time, he felt that he was looked
upon as a curiosity, but not as one claiming sympathy and love as a
relative or dear friend. Did the experiment come up to the ideal?
Was he satisfied to die and live again? He asked these questions of
himself. He meditated—reflected—and slept.
CHAPTER XI

It was 1:25 dial when the Chicago Pneumatic glided noiselessly


into the switching section at Washington. Seizing their grips and
coats, the party moved out on to the platform of the sleeper. In a
moment the huge train had been raised by the hydraulic lift, and
was soon standing in the depot of the capital of the United States.
What a beautiful and fairy-like scene presented itself to Junius
Cobb! A depot of magnificent proportions, exquisite workmanship
and finish, and possessing a hundred conveniences never dreamed
of in his time. The great vaulted roof was set with thousands of
electric lights which appeared like brilliant stars in the firmament.
Thousands more, in every direction and in every conceivable place,
made the vast chamber as bright as the midday sun.
At the barriers of the discharging section a great but orderly crowd
was pushing and elbowing its way to a closer position at the gate. All
Washington knew that Junius Cobb, the man of two centuries ago,
would arrive on that particular train, and a great multitude had
congregated to catch a glimpse of him.
As he passed through the gates, while the police pushed back the
crowd, he heard their exclamations and remarks:
“There he is!”
“Where?”
“There, with Commissioner Rawolle—on his left.”
“I believe him to be a fake.”
“Oh, he’s a toola!”
“He has never slept a hundred years!”
“Isn’t he a young man to have lived so long?”
“What’s the matter with you? he didn’t live, he just slept.”
“They say he is an officer in the army yet.”
“Well, people will be gulled!”
Thus were the expressions bandied about, and fell upon the ears
of Cobb in a harsh and unpleasant manner. He was not flattered by
the remarks he heard. Already, it seemed, there was a desire to
doubt his identity.
As they neared the center of the hall, someone in the crowd cried:
“Junius Cobb! Junius Cobb! Three cheers for Junius Cobb!” And the
building rang and echoed back the salutation. Surely this was
flattering. His reception, after all, was not without sincerity on the
part of many of that vast throng.
A step or two more, and Cobb and Rawolle entered an electric
drag, while Lyman bade them good-night, or rather good-morning,
and hurried away to report.
Away, and at a rapid gait, sped the drag, its wheels of rubber
giving no sound on the elastic pavement of the street, its headlight
flashing out a brilliant beam, while ever and anon the driver caused
a muffled-toned gong, whose sound was low and musical, to
indicate the approach of the carriage.
Looking from the window on his side, Cobb saw to what extent
street illumination had progressed in a hundred years. At every fifty
feet, on either side, were arc lamps; and this at two in the morning,
when those of the shops were extinguished. No gas lights were
visible. It was a September morning, but the air was mild and balmy,
and it seemed like a morning in early spring. Many people were
upon the street, and the electric drags, with their flashing lights and
musical gongs, were passing in every direction.
At exactly 1:42 dial the drag stopped under the arch of the
entrance to the President’s mansion, and Junius Cobb was received
by the chief magistrate of the United States.
Emory D. Craft, President of the United States, was a tall, rotund,
and pleasant gentleman of over sixty years of age. His head was
massive, and his features square and clean-cut; his hair almost
white, and a beard heavy and gray. A man of great perception,
executive ability, true kindness, and wisdom, he ruled the greatest
nation on earth as a loving father rules his household, with justice
and firmness.
As Rawolle and Cobb alighted, he descended the steps, and,
advancing, extended his hand to the former, exclaiming:
“I welcome you back, Mr. Rawolle.”
“Thank you, sir; and let me present Mr. Junius Cobb.”
“Mr. Cobb, I cannot express to you the pleasure of this meeting;”
and the President shook the young man’s hand heartily. “Be assured
that your remarkable, nay, wonderful, case has been uppermost in
my mind since first I became aware of your existence.”
“Nor can I, Mr. President, express the gratification I feel in
meeting and shaking the hand of the chief magistrate of this great
nation, especially when that magistrate is ruling the country a
hundred and forty years after my birth.”
Cobb seemed proud of the fact that he, of all the world, could
make such a statement.
A few moments later, the President and Cobb were sitting before a
glowing, cheerful fire, engaged in earnest conversation.
Mr. Rawolle had been dismissed by the President, and had
hastened to the welcome he knew awaited him from his wife and
children.
“There, Mr. President,” said Cobb, after a long recital of his life and
the facts attending his entombment on Mt. Olympus, “you have the
whole story. It is a remarkable one, is it not?”
“Stranger than any fiction I ever read,” he exclaimed. “I can
scarcely believe that I behold the intimate friend and contemporary
of my great-grandfather in the person of one so young as you.”
He looked at Cobb in wonder and awe.
“And are you the great-grandson of Hugh Craft, my dear old friend
of 1887?” cried Cobb with joy, as if a new tie had been found to bind
him to this new world.
“Yes; here is our family history.” He arose and went to the cabinet,
and returned with a large book. “Read it;” opening it and handing it
to the other; “you will there see the history of your friend.” He
placed his finger on the page.
Cobb read slowly, and like one in a dream, this page of the history
of the dead—this chronicle of the life of his chum and bosom friend.
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

textbookfull.com

You might also like