Kathryn shows you the solution to the "Create a Blueprint and an Instance" challenge. In the solution, Kathryn creates a Dog class with three properties and three methods. She also creates an instance of the Dog class in the main method of the Main class, and calls one of the Dog class’s methods.
- [Narrator] Here's a solution to the previous…create a blueprint in instance challenge.…I've chosen to represent a dog in code,…and so I've created a dog class.…Here, our dog has a name, age, a series of fetched items,…and a private fetch counter.…Here, our name is a string, our age is an int,…the series of fetched items is a string array,…and then our fetch counter is a private int.…We also have a constructor,…and this is how we're going to make dogs.…This is how dogs are created.…
Every dog that we create needs to have a name and an age,…and so basically when you create the dog,…you have to give it that as an input.…We'll see this more in the main method.…And then another method we have here is called bark.…And bark just prints out bark when you call it.…We also have get dog years, and it returns the dog years…depending on what age the dog is currently.…And our last method here is fetch,…and fetch, this is basically the dog fetching…a series of items or fetching one item…out of that series of items,…and the first thing we do in this method…
Author
Released
3/21/2018- Downloading Java 9 and choosing an IDE
- Understanding Java basics: data types, strings, arrays, and more
- Controlling flow with functions and loops
- Debugging
- Working with inheritance and interfaces
- Learning lambda
Skill Level Beginner
Duration
Views
-
Introduction
-
Welcome34s
-
-
1. Getting Started
-
Exploring JShell3m 50s
-
Exploring an IDE2m 11s
-
Hello World in Java4m 6s
-
2. Java Basics
-
How do we create code?2m 8s
-
Variables and data types4m 6s
-
Strings7m 12s
-
Arrays8m 48s
-
Exploring documentation3m 1s
-
-
3. Control Flow
-
Decision-making with IF5m 37s
-
Comparing loops5m 18s
-
Debugging with an IDE4m 16s
-
Solution: Dice Roll4m 3s
-
4. Beyond the Basics
-
What is encapsulation?6m 40s
-
Working with inheritance9m 12s
-
Interfaces6m 6s
-
Functional programming1m 4s
-
Learning lambda7m 14s
-
Conclusion
-
Next steps37s
-
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.
CancelTake notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.
Share this video
Embed this video
Video: Solution: Create a Blueprint and an Instance