Question 1: Suppose you are working on an object-oriented module for the sale and purchase of sacrificial animals. Major Classes are Seller, Dealer, Animal, Buyer, and Invoice. Details of the classes can be seen in Table 1. Note that the system does not store information about individual person, apart from the Seller, dealer, or a buyer. Write Java code for the class declaration, instance variables, and constructors for all the classes. Use inheritance and composition where required. You can create new class(es) if needed, with explanation in comments.
Q2
Your code must ensure that all the relevant classes Seller, Dealer, Buyer, and distinct classes
Animal and Invoice implement a common method for maintaining the finances. Details of the
classes can be seen in Table 1. Explain with proper syntax as to how this can be achieved using
object-oriented programming, highlighting the changes you will need to make in the class
declarations in Question 1
Q1 code is down below
package com.company.sale;
public class Animal {
int tag;
double price,weight,serviceCharge;
String color,date;
Boolean sold;
public static void main(String[] args) {
Animal Cow=new Animal();
}
}
class Dealer extends Animal{
String dname,address;
double commission,earning;
long pno,id;
void earning(){
return earning;
}
}
class Seller{
String name,address;
long id;
double profitRate,salesTax,profit;
void SalesTaxProfit()
{
return profit*salesTax/100;
}
}
class Buyer{
String name,address;
long id,contact;
double amt;
void amt()
{
return amt;
}
}
![Question 1: Suppose you are working on an object-oriented module for the sale and purchase of
sacrificial animals. Major Classes are Seller, Dealer, Animal, Buyer, and Invoice. Details of the classes
can be seen in Table 1. Note that the system does not store information about individual person, apart from
the Seller, dealer, or a buyer. Write Java code for the class declaration, instance variables, and constructors
for all the classes. Use inheritance and composition where required. You can create new class(es) if needed,
with explanation in comments.
Table1:
Attributes
Type (Cow, Goat, Lamb etc), a unique identification tag, color, weight, price per kg, the
date of arrival of the Animal to the dealership, service charges, and whether the Animal is
sold or not.
dealer's name, dealer's id, dealer's address, the dealer's phone number, and the commission
rate. The dealer object also keeps track of the Animals that the dealer has. It includes a
method that calculates the earning of the dealer
Seller's name, id, address, contact, profit rate and sales tax rate. Includes methods to
calculate the sales tax on the profit and after tax profit of the seller
Name, id, address, contact. Includes a method to calculate the amount the buyer has to pay
Class
Animal
Dealer
Seller
Buyer](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F4c0302c3-9463-45ae-ba24-48b4ac042a0f%2F0f993ca8-1a60-4ed1-9a84-73fca1a9f308%2F87rhi36_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 2 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)