1. Homepage
  2. Programming
  3. Homework3: Develop a simple pet store application

Homework3: Develop a simple pet store application

Engage in a Conversation
Pet StoreJava

Homework3

● Conciseness, Formatting & Documentation: 3 points – Reserved for concise solution, good Javadoc, and formatting. ● Points: Phase #1: 2 points per class – 2×9=18 points total. Phase #2: 10 points. CourseNana.COM

Project Overview:

An object-oriented solution is being developed for a pet shop that has different types of pets and food for them. CourseNana.COM

Phase#1: Develop hierarchy of classes from UML

Analyzing the user’s requirements, a hierarchy of classes has been designed. In this part of the project, you are required to develop the Java source code (9 different classes) corresponding to the class hierarchy shown below: CourseNana.COM

Inside the Thing class: the getKind(), isAquatic(), and getPrice() methods are in italic which means they are abstract methods CourseNana.COM

Notes on specific of the methods

  1. The return value of getKind method should be as follows: ▪ For Pet objects (Cat, Fish, Octopus. Dog), the return value of the getKind must be the kind value but with class name as prefix. For e.g., “Cat: Maincoon”, “Dog: Poodle” etc. ▪ For Food objects (WormCan, ChowBag) , the return of the getKind method must be just the name of the class as in “WormCan” or “ChowBag”.
  2. Note the following toString output format: ▪ For Pets the toString representation is generated via (example for Cat class): String.format("%s\t%s\t%.2f\t%.2f", "Cat", kind, price, foodPerDay); ▪ For Foods the toString representation is generated via (example for WormCan class): String.format("%s\t%.2f\t%.2f", "WormCan", price, weight);
  3. Notes for the equals methods in Pet and Food classes: ▪ Two Pet objects are equal if they are of the same Java-class (use instanceof keyword for comparing classes), and have the same kind values. And, ignore price and foodPerDay in comparisons. ▪ Two Food objects are equal only if they are of the same Java-class (use instanceof keyword for comparing classes), and have the same price and weight.
  4. For the isAquatic methods, simply return false inside Cat and Dog classes, and return true for Octopus and Fish classes.

Testing for Phase #1:

You are expected to develop your own approach to test your classes • Test each class as you develop them • For each class test, ensure you are able to create an object from that class • Print the values returned by different methods to ensure they are consistent . CourseNana.COM

Phase #2: Complete methods in the PetShop source

In this phase of the project, you will be using the classes you developed in the previous phase to develop a simple pet store application. You are already given starter code with method stubs in PetShop.java for you to complete. Use the Javadoc for the methods and sample outputs shown below to implement the various methods in PetShop.java. CourseNana.COM

Testing for Phase #2:

For this phase of testing a simple PetShopUI.java program is already supplied to you. Review this program and use it for testing methods in PetShop. Sample outputs are shown below (user inputs are in green color) CourseNana.COM

Test #1: Loading things from a text file Welcome to the Pet Shop (0 pets & 0 food things). What would you like to do [0 for menu]: 0 CourseNana.COM

  1. To add things from a text file
  2. Print summary of things.
  3. Print all things
  4. Print food status
  5. Show this menu -1. Quit Welcome to the Pet Shop (0 pets & What would you like to do [0 for Enter file name to add inventory: Welcome to the Pet Shop (7 pets & What would you like to do [0 for

Test #2: Load and print things Welcome to the Pet Shop (0 pets & What would you like to do CourseNana.COM

Welcome to the Pet Shop (7 pets &
What would you like to do [0 for
List of all items:
Fish Goldfish 4.75 0.02
Fish Guppy 1.25 0.01
Octopus Argonaut 99.99 0.03
ChowBag 17.50 2.50
WormCan 5.75 1.00
WormCan 5.75 1.00
Dog Poodle 725.00 0.30
Dog Bulldog 450.50 0.20
Cat Persian 1400.00 0.10
Cat Meincoon 325.00 0.15
Welcome to the Pet Shop (7 pets & What would you like to do

Test #3: Load and print summary of things Welcome to the Pet Shop (0 pets & What would you like to do [0 for Enter file name to add inventory: Welcome to the Pet Shop (7 pets & What would you like to do [0 for Summary of items in Pet Shop Aquatic pets & food summary Number of pets : 3 Total price pets : $105.99 Number of food items: 2 Total price of food : $11.50 Non-aquatic pets & food summary Number of pets : 4 Total price pets : $2900.50 Number of food items: 1 Total price of food : $17.50 Welcome to the Pet Shop (7 pets & What would you like to do [0 for CourseNana.COM

0 food things). menu]: 1 few_things.txt 3 food things). menu]: -1 0 food things). menu]: 1 few_things.txt 3 food things). menu]: 3 CourseNana.COM

3 food things). menu]: -1 CourseNana.COM

0 food things). menu]: 1 few_things.txt 3 food things). menu]: 2 CourseNana.COM

3 food things). menu]: -1 CourseNana.COM

Test #4: Load and print food status

Welcome to the Pet Shop (0 pets & 0 food things). What would you like to do [0 for menu]: 1 Enter file name to add inventory: few_things.txt Welcome to the Pet Shop (7 pets & 3 food things). What would you like to do [0 for menu]: 4 Pet Shop food status: Daily aquatic food needed : 0.06 lb Daily non-aquatic food needed : 0.75 lb Aquatic food stock in store : 2.00 lb Non-aquatic food stock in store: 2.50 lb Welcome to the Pet Shop (7 pets & 3 food things). What would you like to do [0 for menu]: -1 CourseNana.COM

USE DEBUGGER: CourseNana.COM

Submission:

This homework assignment must be turned-in electronically via Canvas CODE plug-in. Ensure your program compiles successfully, without any warnings or style errors. Ensure you have documented the methods. Ensure you have tested operations of your program as indicated. Upload the following to Canvas via the CODE plug-in: CourseNana.COM

  1. Phase #1: The 9 Java source files developed for this phase of the project.
  2. Phase #2: The 9 classes and PetShop.java

Frequently asked questions: CourseNana.COM


Are any of these 9 classes supposed to be abstract classes? Yes, the Thing class. CourseNana.COM


Why the Pet and Food classes are also in italic. Are they also supposed to be abstract?? If you are not implementing some of the abstract methods from the Thing class inside the Pet or Food class (which is exactly what you should do based on the instructions), then you also need to define the Pet and Food classes as abstract. That way you are telling java that those abstract methods will be implemented later by children of Food or Pet. CourseNana.COM

*** The plugin is saying my .equals() methods aren't working correctly but I made a test class and both methods seem to be working fine (as seen in picture). I am really not sure where to go from here and how to approach fixing my methods. The Code checks the classes to make sure objects are also from the same family. Make sure to check objects using instanceof instead of getClass() method. Also, ensure that you are overriding the .equals method inside the Pet and Food classes. CourseNana.COM


Also, should we use standard javadoc for abstract methods? Yes. Same rules. CourseNana.COM


I was wondering how we are supposed to use the Thing class/ constructor. Are we supposed to be using it as an abstract constructor and use the pet and food classes to actually create the Thing? You can create the Thing class as an abstract class. Thing() is a default constructor, you don't really have to do anything inside the default constructor, you can just leave the body of the Thing() constructor empty and you'll be fine. Constructors can't be abstract. CourseNana.COM


Should I choose "abstract" at the modifier part when creating a class? Because when I chose that option, Eclipse created an abstract class in a package named "homework3" Yes, if you want to create an abstract class then you have to add the keyword abstract to the class header. CourseNana.COM


What do you do for the isAquatic method? Don’t overthink it. The isAquatic is just a method that returns a boolean value either true or false. If you are writing this method inside a dog class, then it’s not aquatic so this method inside this class should return false, that’s it. CourseNana.COM


Can I call getKind() methods from either Food or Pet? You can always use methods/variables available inside the class or from higher classes like a parent or grandparent class. But, you can't use things from other classes that haven’t been implemented yet either in the current class or in higher classes. For example: the getKind method hasn't been implemented yet in Pet class so you should not use it. Also, when you are using instance variables that are inherited from another class, don't forget using the keyword super, not this. CourseNana.COM


Get in Touch with Our Experts

WeChat (微信) WeChat (微信)
Whatsapp WhatsApp
Pet Store代写,Java代写,Pet Store代编,Java代编,Pet Store代考,Java代考,Pet Storehelp,Javahelp,Pet Store作业代写,Java作业代写,Pet Store编程代写,Java编程代写,Pet Storeprogramming help,Javaprogramming help,Pet Storeassignment help,Javaassignment help,Pet Storesolution,Javasolution,