Answered step by step
Verified Expert Solution
Question
1 Approved Answer
CSE 110: Principles of Programming Languages Assignment 5 Overview In this assignment you will write a program that will model a pet store. The program
CSE 110: Principles of Programming Languages Assignment 5 Overview In this assignment you will write a program that will model a pet store. The program will have a Pet class to model individual pets and the Assignment5 class will contain the main and act as the pet store. Users will be able to view the pets, make them age a year at a time, add a new pet, and adopt any of the pets. Note: From this point on, your assignments will require multiple files. If you want to keep things easily organized, you may want to create a new project within your IDE to keep these files separate from all the others Requirements Your program must do the following in order to receive full credit on this assignment. 1. Create a new public class callcd Pet in its own filc. a. Remember that class and file name must match. 2. Create three private instance variables a. b. c. The name of the pet. The age of the pet. Whether the pet is adopted or not. 3. Create a default constructor for the Pet class. Remember that a default constructor takes no arguments and assigns meaningless values to the instance variables. a. 4. Create a second constructor for Pet that takes a name and age as arguments a. Assign these values to the instance variables. Pets always start off un-adopted. 5. 6. b. Provide a get and set for the name instance variable Provide a get for age, but instead of a regular set create a method that increases age by 1 a. Keep in mind that this age increase method will need to be public 7. Provide a get for the adopted variable and instead of a set provide a public method which sets this adoption variable to true. Note: This is the last thing you will do in Pet. The rest of these steps are done in your main program file a. 8. Create a Scanner object that will be visible to all methods in Assignment5 a. This object will need a particular modifier. What is it? CSE 110: Principles of Programming Languages Assignment 5 Overview In this assignment you will write a program that will model a pet store. The program will have a Pet class to model individual pets and the Assignment5 class will contain the main and act as the pet store. Users will be able to view the pets, make them age a year at a time, add a new pet, and adopt any of the pets. Note: From this point on, your assignments will require multiple files. If you want to keep things easily organized, you may want to create a new project within your IDE to keep these files separate from all the others Requirements Your program must do the following in order to receive full credit on this assignment. 1. Create a new public class callcd Pet in its own filc. a. Remember that class and file name must match. 2. Create three private instance variables a. b. c. The name of the pet. The age of the pet. Whether the pet is adopted or not. 3. Create a default constructor for the Pet class. Remember that a default constructor takes no arguments and assigns meaningless values to the instance variables. a. 4. Create a second constructor for Pet that takes a name and age as arguments a. Assign these values to the instance variables. Pets always start off un-adopted. 5. 6. b. Provide a get and set for the name instance variable Provide a get for age, but instead of a regular set create a method that increases age by 1 a. Keep in mind that this age increase method will need to be public 7. Provide a get for the adopted variable and instead of a set provide a public method which sets this adoption variable to true. Note: This is the last thing you will do in Pet. The rest of these steps are done in your main program file a. 8. Create a Scanner object that will be visible to all methods in Assignment5 a. This object will need a particular modifier. What is it
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started