


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
Material Type: Notes; Professor: Hanks; Class: Intro to Programming in Java; Subject: Computer Science Info Systems; University: Fort Lewis College; Term: Unknown 1989;
Typology: Study notes
1 / 4
This page cannot be seen from the preview
Don't miss anything!
Reading: Appendix E (pages 432-434) Quiz Wednesday. Covers material up through last lecture. Main So far, we have only executed our java classes inside of BlueJ. What if we wanted to share a program with someone else? Let's run my tic-tac-toe program. In order to do this, one of the classes in our program must contain a method with this signature: public static void main( String[] args ) Let's look at the parts:
Lab 24 Create a new BlueJ project. Create a class Pet in the project. Pet's have three attributes: a name, a kind (such as "dog", "cat", or "goldfish"), and an age. Define instance variables in the Pet class for these attributes. Use an int for the age variable. Define a constructor in class Pet that has three formal parameters (give them the same names as the instance variables). The constructor initializes the instance variables with the value of the parameters. Define a toString method in class Pet. This method should return a String that contains the state of a Pet object. For example, if you have a dog named Fido that is 4 years old, toString should return something like: Fido the dog is 4 years old Now, create a second class in the project – name this class PrintPet. Create a main method in class PrintPet. The main method should: