Answered step by step
Verified Expert Solution
Question
1 Approved Answer
PLEASE WRITE CODE IN JAVA You are going to develop a class to represent Products. *For the instance variables, add the below ones. Make sure
PLEASE WRITE CODE IN JAVA
You are going to develop a class to represent Products. *For the instance variables, add the below ones. Make sure that these values cannot be accessed from other classes. Name of the product Price of the product Number of purchases *Write at least two constructors (not the default one) (Hint: When you first create a product, purchases should be 0) *For this class, make sure you follow the encapsulation rules. (Add methods that you think are necessary for encapsulation) *Add an additional buy method that increases the purchase amount *Override the toString method. Return everything in a proper format. *Implement a class that will represent a Category. *For the instance variables, add the below ones. Make sure that these values cannot be accessed from other classes. name of the category number of products products[] *Write at least two constructors (not the default one) *For this class, make sure you follow the encapsulation rules. (Add methods that you think are necessary for encapsulation) *Implement a class that will represent a Category. *For the instance variables, add the below ones. Make sure that these values cannot be accessed from other classes. name of the category number of products products[] *Write at least two constructors (not the default one) *For this class, make sure you follow the encapsulation rules. (Add methods that you think are necessary for encapsulation) *Write one additional method to add products to a category. *Write one additional method to search a product by the product's name in this category. If you can find it, return it. *Write one additional method to search a product by the price in this category. If you can find a product or products with that price, display them. *Write another method to decide the top-selling product in this category, display it. (which is the most purchased product.) *Override the toString method. Return everything including the product names. *Finally, use this class with a main method. Create a couple of products. Then create a category with these products. Buy them randomly. Search the products, call the necessary methods and at the end show us which product is the top product and which one is the most expensive one. The general flow is up to you but make sure you call search methods, buy method, add method and tostring methodsStep 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