Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed Java Basics!
You have completed Java Basics!
Preview
In this video, we go over the specifications for the program and flesh out our prototype.
Boilerplate
// __name__ is a __adjective__ __noun__. They are always __adverb__ __verb__.
String name = console.readLine("Enter a name: ");
String adjective = console.readLine("Enter an adjective: ");
String noun = console.readLine("Enter a noun: ");
String adverb = console.readLine("Enter an adverb: ");
String verb = console.readLine("Enter a verb ending with -ing: ");
Resources
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
We're all set to build our tree story
prototype.
0:01
To prove it works, let's create
a little story that asks the user for
0:03
different parts of speech.
0:07
If you want to, you can pause the video
now, head over
0:08
to your workspace,
and try coding this yourself before I do.
0:12
Ready? Let's go.
0:15
Alrighty,
first things first, let's clear out
0:16
the old code we've been working on here.
0:20
Okay, and let's type a comment
for what we want to build.
0:25
We'll say name is a,
0:30
or an, adjective, noun.
0:34
They are always adverb, verb.
0:38
These blanks will be filled in
by the user.
0:45
Since we've practiced prompting
for input a few times now, I'm confident
0:49
you got this.
0:54
The prompts you'll need are in
the teacher's notes underneath the video.
0:55
So I'm going to copy
those and paste them in.
0:59
Go ahead and do the same.
1:01
You'll see variables for name, adjective,
1:03
noun, adverb, and verb.
1:08
Nice. Next, let's print
a heading to start the story nicely.
1:12
Let's do Your Tree Story.
1:22
And let's add a new line.
1:26
Let's add a line of dashes as a separator
1:30
and a few more new lines
to space things out nicely.
1:34
Now for the story itself, use
console.printf %s is a %s %s.
1:39
And we want to plug in the name,
1:50
then the adjective,
1:53
and then the noun.
1:56
Oh, let's make sure to leave a space
after the period
2:00
since these are going to end up
on the same line.
2:02
We want some separation there.
2:05
Next we can go console.printf.
2:08
They are always, %s %s.
2:13
And let's end it with a new line.
2:19
Lastly, we want our adverb
and then the verb.
2:22
Remember that the printf method
2:28
will replace each placeholder
with the variables you pass along.
2:30
Okay, let's save and run the program.
2:34
Here's the first prompt,
I'll enter a name.
2:42
Let's say Rohald.
2:44
Adjective, incredible.
2:46
Noun, coder.
2:52
Adverb, quickly.
2:55
And a verb ending in "ing", hacking.
2:59
And the output is,
Rohald is an incredible coder.
3:04
they are always quickly hacking.
3:06
I see a little bug in our English here.
3:08
We should remember that
anytime we use an A, we should add
3:12
a parentheses N after for following words
starting with a vowel.
3:15
Hmm, I wonder what other bugs
3:19
are hiding, waiting to be found.
3:22
Great job building this prototype!
It definitely deserves a beta sticker.
3:24
And we did find a small error
that only shows up when we run it
3:29
with input from a user.
The Java compiler tries hard to catch
3:33
errors early but some mistakes only appear
during execution.
3:37
While this one was just
3:41
a small flaw in our logic,
there are others
3:42
that can be introduced
that can be catastrophic.
3:44
Since these errors can only be caught when
3:47
the program is running,
they're called runtime errors.
3:49
To catch runtime errors before releasing
software, teams use various methods.
3:53
Most commonly,
a team of QA engineers,
3:58
short for quality assurance,
runs thorough tests.
4:01
Automation
has become a big part of testing,
4:04
with some teams having developers
write automated tests themselves.
4:07
Another way to find bugs is beta testing.
4:11
Releasing the software
to a small group of users.
4:14
You'd be surprised at the creative ways
these beta testers
4:17
figure out how to break your program.
4:19
Limiting the number
of users keeps frustration low
4:22
while still catching important errors.
4:26
I'm going to send this program
to my fellow teachers as beta testers.
4:28
Any bugs they find, we'll fix
before the final release.
4:32
Sound good?
4:35
Okay, one last prototyping exercise
before we start improving our product.
4:36
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up