Please write a java code for this Codes are posted below for editing.
***Main Class****
public class Main {
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
PetStore ps = new PetStore("Insert Petstore name here");
System.out.println("**** Welcome to " + ps.getStoreName() + "****");
while (true) {
System.out.println("Please select from one of the following menu otions");
System.out.println("t1. Buy a new pet");
System.out.println("t2. Register a new member");
System.out.println("t3. Start adoption drive (add new pets)");
System.out.println("t4. Check current inventory");
System.out.println("t5. Register new pet to Owner profile");
System.out.println("t6. Exit");
int choice1 = scnr.nextInt();
switch (choice1) {
case 1:
System.out.println("What type of pet are you here to purchase?");
System.out.println("t1. Dogs");
System.out.println("t2. Cats");
System.out.println("t3. Exotic Pets");
// Add/Change code here
break;
case 2:
break;
case 3:
break;
case 4:
break;
case 5:
break;
case 6:
System.out.println("Thanks for visiting!");
return;
default:
System.out.println("Invalid choice, try again.");
}
}
}
}
****Pet Store*****
import java.util.*;
public class PetStore {
private String storeName;
private ArrayList<Dog> availableDogs = new ArrayList();
private ArrayList<Cat> availableCats = new ArrayList();
private ArrayList<ExoticPet> availableExoticPets = new ArrayList();
private ArrayList<Member> memberList = new ArrayList();
private ArrayList<PremiumMember> premiumMemberList = new ArrayList();
private static int nextPetID = 1;
public PetStore(String storeName) {
this.storeName = storeName;
Dog dog1 = new Dog("Kaylee", "German Shepherd", "Female", 12, 85, getNextPetID(), 500);
Dog dog2 = new Dog("Poe", "Corgi", "Male", 3, 35, getNextPetID(), 450);
Cat cat1 = new Cat("Karma", "Orange Tabby", "Female", 6, 15,getNextPetID(), 200);
Cat cat2 = new Cat("Kit", "Maine Coon", "Male",6, 18, getNextPetID(), 150);
ExoticPet ep1 = new ExoticPet("Pancake", "Bearded Dragon", "Male", 6, 0.8, getNextPetID(), 75);
ExoticPet ep2 = new ExoticPet("Noodle", "Ball Python", "Male", 4, 2, getNextPetID(), 95);
availableDogs.add(dog1);
availableDogs.add(dog2);
availableCats.add(cat1);
availableCats.add(cat2);
availableExoticPets.add(ep1);
availableExoticPets.add(ep2);
Member member1 = new Member("Jo", 234, true);
member1.addCat(new Cat("Valjean", "White tabby", "Male",1,10,0,0));
PremiumMember member2 = new PremiumMember("Sage", 567, false, true);
member2.addExoticPet(new ExoticPet("Smaug", "Bearded Dragon", "Male", 5, 1, 0,0));
}
public static int getNextPetID() {
nextPetID++;
return nextPetID-1;
}
public String getStoreName() {
return storeName;
}
public void setStoreName(String storeName) {
this.storeName = storeName;
}
public ArrayList<Dog> getAvailableDogs() {
return availableDogs;
}
public void setAvailableDogs(ArrayList<Dog> availableDogs) {
this.availableDogs = availableDogs;
}
public ArrayList<Cat> getAvailableCats() {
return availableCats;.
Please write a java code for this Codes are posted below for.pdf
1. Please write a java code for this Codes are posted below for editing.
***Main Class****
public class Main {
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
PetStore ps = new PetStore("Insert Petstore name here");
System.out.println("**** Welcome to " + ps.getStoreName() + "****");
while (true) {
System.out.println("Please select from one of the following menu otions");
System.out.println("t1. Buy a new pet");
System.out.println("t2. Register a new member");
System.out.println("t3. Start adoption drive (add new pets)");
System.out.println("t4. Check current inventory");
System.out.println("t5. Register new pet to Owner profile");
System.out.println("t6. Exit");
int choice1 = scnr.nextInt();
switch (choice1) {
case 1:
System.out.println("What type of pet are you here to purchase?");
System.out.println("t1. Dogs");
System.out.println("t2. Cats");
System.out.println("t3. Exotic Pets");
// Add/Change code here
break;
case 2:
break;
case 3:
break;
case 4:
break;
case 5:
break;
case 6:
System.out.println("Thanks for visiting!");
return;
default:
2. System.out.println("Invalid choice, try again.");
}
}
}
}
****Pet Store*****
import java.util.*;
public class PetStore {
private String storeName;
private ArrayList<Dog> availableDogs = new ArrayList();
private ArrayList<Cat> availableCats = new ArrayList();
private ArrayList<ExoticPet> availableExoticPets = new ArrayList();
private ArrayList<Member> memberList = new ArrayList();
private ArrayList<PremiumMember> premiumMemberList = new ArrayList();
private static int nextPetID = 1;
public PetStore(String storeName) {
this.storeName = storeName;
Dog dog1 = new Dog("Kaylee", "German Shepherd", "Female", 12, 85, getNextPetID(), 500);
Dog dog2 = new Dog("Poe", "Corgi", "Male", 3, 35, getNextPetID(), 450);
Cat cat1 = new Cat("Karma", "Orange Tabby", "Female", 6, 15,getNextPetID(), 200);
Cat cat2 = new Cat("Kit", "Maine Coon", "Male",6, 18, getNextPetID(), 150);
ExoticPet ep1 = new ExoticPet("Pancake", "Bearded Dragon", "Male", 6, 0.8, getNextPetID(), 75);
ExoticPet ep2 = new ExoticPet("Noodle", "Ball Python", "Male", 4, 2, getNextPetID(), 95);
availableDogs.add(dog1);
availableDogs.add(dog2);
availableCats.add(cat1);
availableCats.add(cat2);
availableExoticPets.add(ep1);
availableExoticPets.add(ep2);
Member member1 = new Member("Jo", 234, true);
member1.addCat(new Cat("Valjean", "White tabby", "Male",1,10,0,0));
PremiumMember member2 = new PremiumMember("Sage", 567, false, true);
member2.addExoticPet(new ExoticPet("Smaug", "Bearded Dragon", "Male", 5, 1, 0,0));
}
public static int getNextPetID() {
3. nextPetID++;
return nextPetID-1;
}
public String getStoreName() {
return storeName;
}
public void setStoreName(String storeName) {
this.storeName = storeName;
}
public ArrayList<Dog> getAvailableDogs() {
return availableDogs;
}
public void setAvailableDogs(ArrayList<Dog> availableDogs) {
this.availableDogs = availableDogs;
}
public ArrayList<Cat> getAvailableCats() {
return availableCats;
}
public void setAvailableCats(ArrayList<Cat> availableCats) {
this.availableCats = availableCats;
}
public ArrayList<ExoticPet> getAvailableExoticPets() {
return availableExoticPets;
}
public void setAvailableExoticPets(ArrayList<ExoticPet> availableExoticPets) {
this.availableExoticPets = availableExoticPets;
}
public ArrayList<Member> getMemberList() {
return memberList;
}
public void setMemberList(ArrayList<Member> memberList) {
this.memberList = memberList;
}
public ArrayList<PremiumMember> getPremiumMemberList() {
return premiumMemberList;
}
public void setPremiumMemberList(ArrayList<PremiumMember> premiumMemberList) {
this.premiumMemberList = premiumMemberList;
}
}
****Dog***
4. public class Dog {
private String name;
private String breed;
private String sex;
private int age;
private double weight;
private int ID;
private double price;
public Dog(String name, String breed, String sex, int age, double weight, int ID, double price) {
this.name = name;
this.breed = breed;
this.sex = sex;
this.age = age;
this.weight = weight;
this.ID = ID;
this.price = price;
}
public int getID() {
return ID;
}
public void setID(int ID) {
this.ID = ID;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
***Cat****
public class Cat {
private String name;
5. private String breed;
private String sex;
private int age;
private double weight;
private int ID;
private double price;
public Cat(String name, String breed, String sex, int age, double weight, int ID, double price) {
this.name = name;
this.breed = breed;
this.sex = sex;
this.age = age;
this.weight = weight;
this.ID = ID;
this.price = price;
}
public int getID() {
return ID;
}
public void setID(int ID) {
this.ID = ID;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
***Exotic Pets****
public class ExoticPet {
private String name;
private String species;
private String sex;
private int age;
private double weight;
private int ID;
private double price;
public ExoticPet(String name, String species, String sex, int age, double weight, int ID, double
price) {
this.name = name;
this.species = species;
6. this.sex = sex;
this.age = age;
this.weight = weight;
this.ID = ID;
this.price = price;
}
public int getID() {
return ID;
}
public void setID(int ID) {
this.ID = ID;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
Part A - Inheritance, Abstraction and Interfaces (10 points) In this part we want to introduce
inheritance and abstraction into our system. Update this design to utilize inheritance when
representing the different pets the store sells. At a minimum your design should incorporate an
abstract class that is sub-classed into the three different pets available for purchasing - dogs, cats,
and exotic pets. This class must be an abstract class that implements the Comparable interface.
When comparing pets we want that to be either based on the price of the pet or the number of
pets of that type in stock. Choose one of those attributes and implement the compareTo method to
work based on that field. Part B - More Interfaces ( 10 points) In this part you want to update your
PetStore class to implement the following interface: PetStoreSpecification Notice that this interface
has only two methods: adoptionDrive(ArrayList<Object>, double) and inventoryValue(). The Object
class here refers to the parent class for Dog, Cat and ExoticPet. We expect one parent class for
the three pet types but you might choose a different class inheritance hierarchy make sure to note
that clearly with your submission. You might decide to have a separate inventory management
class that might be a better place to implement this interface. You are encouraged to discuss your
design with the instructional team for feedback on your project design. Keep in mind that with
computational problem solving and design there are many ways of achieving a solution. Explore
and have fun with it!Part C - Changing the Test Harness (6 points) Update the Main class to
include menu options to test the functionality added in Parts A (Comparing products) and B
(restock a product and display inventory total). Keep in mind here that you can add helper
methods to your class to make the code cleaner and easier to debug. Part D - Coding Style and
Documentation (4 points) This grade is awarded for proper coding styles. This includes: -
Appropriate prompts and informative output - Appropriate method, variable and object names -
Proper indentation - Proper java documentation - Good commenting (explains what code is doing)
- Well-organized, elegant solution