In this course you will gain all the knowledge you will need to build an interactive command line program in Java. No prior programming experience is required. You will create an interactive game that prompts users for different parts of a sentence and then generates a story using those words.
What you'll learn
Write programs in the Java programming language
Use the console to interact with users
Use basic data types to store and name data
Use conditionals and looping to control program flow
Getting Started with Java
In this stage you will familiarize yourself with Workspaces, your programming environment for this course. We will learn about how to interact with the user using the console object. We will learn about variables, and more specifically, Strings.
Chevron 6 steps
Introduction to Your Tools
Review: Introduction to Your tools
Strings and Variables
Strings, Variables, and Formatting
Using your New Tools
In this stage, you will learn how to add multiple formatters to a format string, and we will have a finished prototype. We will also cover what happens if and when you encounter errors.
Chevron 6 steps
Multiple Format Strings
Coding the Prototype
Fix the Errors
Perfecting the Prototype
In this stage we will apply feedback we received and add feature enhancements to our prototype. We will add an age restriction and make sure that certain words are not allowed. We will explore branching and looping to solve common problems.
Chevron 10 steps
Reviewing Our Feedback
Censoring Words - Using String Equality
Censoring Words - Using Logical ORs
Using Logical ORs and ANDs
Censoring Words - Looping Until the Value Passes
Looping until the value passes
There is a method on string called contains. It checks to see if one string is contained within the other. This seems like a good way to build a master list of words that are not allowed. Why don't you see if what they typed is in a long string of bad words.
After you get that working, attempt to take case into account. If your list of bad words that you maintain is all lower cased, you can check the lower case version of the input in the bad string. How do you make a string lowercase?