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.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

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
Transcribed Image Text: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
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY