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;
}
}
Step by step
Solved in 2 steps