2) (60 pts) (Classes and Methods) For this problem you are going to implement three classes to simulate the underpinning

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

2) (60 pts) (Classes and Methods) For this problem you are going to implement three classes to simulate the underpinning

Post by answerhappygod »

2) (60 pts) (Classes and Methods) Forthis problem you are going to implement three classes to simulatethe underpinnings of an art collectors database. Thedatabase will consist of a Collector class(detailing information about buyers and sellers of art), aTransaction class (including information about atransaction involving any piece of art), and aTransactionDB class (maintaining information abouta collection of transactions and providing some summary informationabout them). More details regarding each class and itsrequired methods follow (<_____> represents a given instancevariable):
1. Collector: A Collector object is createdusing a constructor of the formpublic Collector(int colID, String colName, charcategory), where colID is a numericidentifier, colName is a name of the collectingorganization, andcategory is a character code indicating the organization’snature (ex: ‘C’ might be commercial,‘N’ might be non-profit,etc.) The Collector class must have a toStringmethod that returns a string of the form {<colID>,<colName>, <category>}.
2. Transaction: a Transaction object is createdusing a constructor of the formpublic Transaction(String pieceName, Collector seller,Collector buyer, double sales, int year), where pieceNameis a string description of the art piece, salesPrice and year areself-explanatory, and buyer and seller are Collector objects.The Transaction class requires a toString method thatreturns a string of the form[<pieceName> sold by <seller> to <buyer> in<year> for $<salesPrice>]. Note that<seller> and <buyer> should match theCollector toString output format defined above.
3. TransactionDB: a TransactionDB object iscreated using an empty constructor (i.e. TransactionDB() ), whichshould initialize an empty collection of transactions. It’s up to you to decide the best structure to use for thecollection of transactions. TransactionDB requires thefollowing methods:i. public void add(Transaction newtr): Addsnewtr to the transaction collection.ii. public String toString(): returns a stringconsisting of every individual transaction – each one separated bynewlines.iii. public int numTransactions(): returnsthe total number of transactions in the TransactionDBiv. public double avgRecentCost(): returns theaverage cost of transactions made in the most recentyear within the database.
All instance variables must be private, but you arepermitted (and will almost certainly want) accessor methods. It is highly recommended that you use the TestTransactions.javafile included with the assignment to test your implemented classes,as that will be used to assess that they functioncorrectly. The included text file should give you anidea of the output you should expect from a correctly implementedprogram.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply