Ensure that you read all instructions carefully. Do not include any additional variables or methods that are not specified in this quiz description. Each question is worth one mark and is binary. That is, you either get 1 mark or 0 marks for each question (there are 13 questions on this quiz hence this quiz is worth 13 marks in total). The only application that is to be running on your computer is your IDE (until you are ready to submit your quiz). When you are ready to submit your quiz, please share it on github and ensure that all of your work has been pushed to your repository. Double check this by confirming that your completed classes exist in your repository on github. Submit the link to your repository on Schoology.
Good luck, have fun! :)
- A Dog class will have four instance variables. Ensure that each instance variable is declared as private.
- age (int)
- name (String)
- color (String)
- owner (Owner)
- A Dog class will have one constructor.
- The constructor will have four parameters. The four parameters will be used to initialize the four instance variables.
- A Dog class will have a getter method for each instance variable.
- A Dog class will have a setter method for each instance variable.
- A Dog class will have a private method called addOneAge that is parameterless and increments the age of the Dog.
- A Dog class will have a method called birthday that calls addOneAge and returns the age of the Dog.
- A Dog class will have a toString method that returns, for example, a String in the following format:
- "The dog is named Marlo and is 5 years old. This dog is black." (Quotations are shown to represent that this is a string. The quotations do not need to be included in the returned String.)
- An Owner class will have three instance variables. Ensure that each instance variable is declared as private.
- firstName (String)
- lastName (String)
- phoneNumber (String)
- An Owner class will have one constructor.
- The constructor will have three parameters. The three parameters will be used to initialize the three instance variables.
- An Owner class will have a getter method for each instance variable.
- An Owner class will have a setter method for each instance variable.
Inside the main method ...
- Create an Owner object. The reference to this Owner object should be called owner. The firstName should be “John”, lastName “Wick”, phoneNumber “0800322520”.
- Create a Dog object. The reference to this Dog object should be called dog. The Dog's name should be Jill, age 2, colour black and tan. This should be done in a single statement.
- Use a setter method to change the Dog's name from Jill to Jessie.
- Use a getter method and print statement to print out the age of Jessie. Print out the age only, and use the println method to print. Do this using a single statement.
- Call the birthday method and store this into a variable called age.
- Print out the contents of the variable called age. Use the println method to print.
- Print out the current state of the Dog object. That is, print the reference to the Dog object. This will automatically call the toString method.