![]() To add the pre-lab Animal class in your project. ![]() Download the file Animal.java that contains your pre-lab work, into the lab3Project folder.Start BlueJ, create a new project called lab3Project.Create a new folder on your Desktop, and name it lab3_userName1_userName2.Īll files you work on today should be saved in that folder.Upload the Animal class into gradescope, so you can download it at the start of labĪnd continue working on it. ![]() Compile and run your program.Īlthough you do not expect to see any output yet, you should be able to have an error-free Set up the main() method, where execution will start.Īdd a couple of calls to the constructor you have defined to create some Animal instances. For example, here are a couple sample invocations of your constructor (do not include the property of your choice): /* These are invocations of your constructor */Īnimal doggy = new Animal("dog","Rover","bark",false,4) Īnimal deer = new Animal("reindeer","Rudolph","hi",true,4) Step 3: main() method For this constructor, you can assume that there is an input parameter for each of the instance variables. The job of a constructor is to initialize the values of each instance variable. and one more property of your own choice.number_legs: the number of legs the animal has.canFly: indicates if the animal can fly (true) or not.voice: the sound the animal makes (e.g. ![]() Step 1: instance variables Īlthough there are many properties that one might choose to describe an animal, On your own computer, set up a BlueJ project, add a class named Animal,Īnd add code for the steps below marked as. The User-defined Animal Class Pre-Lab Tasks use of static method - reading from keyboard (Scanner).User-defined classes and objects in java. Lab: Object Oriented Programming Solutions ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |