It can be helpful to have some code in your back-pocket! This back-pocket code shows a Java class for a Dog with (1) an instance variable myAge, (2) a constructor that takes in an int for the initial age of the Dog, (3) a method getOlder() to increment the age of the Dog, (4) a method toString() to return a String that says the Dog's age, and (5) a main method that creates a Dog object, calls getOlder() and prints the Dog. At Harvey Mudd College, we have students memorize a few pieces of "back-pocket code" - Check it out here: tinyurl.com/quizBPC
Back-pocket code: Basic Java class - YouTube | |
2 Likes | 2 Dislikes |
382 views views | 2,205 followers |
Education | Upload TimePublished on 23 Jan 2017 |
Không có nhận xét nào:
Đăng nhận xét