We want to realize a program to handle an archive of records. For each record the following information is stored: name of the author, title of the record, and price.
Write a class
Record that implements the following methods:
Record(String a, String t): constructor that, given author and title, constructs a record whose price is initially 0.0 (the record is not being sold yet);
String toString(): that returns a string with all the information about the record;
void incrementPrice(double p): that increments the price by the amount
String getAuthor(): that returns the author of the record;
String getTitle(): that returns the title of the record;
double getPrice(): that returns the price of the record.
Write a class
UseRecord, client of
contains the following public static methods:
static String titleLowerPrice(Record r1, Record r2): that, given two records
r2, returns the title of the record among
r2with the lowest price. If both records have the same price, the method should return the concatenation of the titles of the two records, separated by a
static double averagePriceAuthor(Record arch, String auth): that, given an archive
archof records, rappresented simply as an array of records, and an author
auth, returns the average price of all records of the author
auththat are being sold (i.e., whose price is greater than 0). If there are no records sold by the author, the method should return 0.