You are asked to write a Java program to calculate the commercial value of the stamps owned by a philatelist. Each philatelist has a name and a collection of stamps. The stamps can be divided into two groups: Group I and Group II. Each stamp has the following attributes: name, face value, and publication year. The commercial value of a stamp is calculated as follows:
1. for a stamp in Group I, the commercial value is twice its face value,
2. for a stamp in Group II, the commercial value is triple its face value.
You need to follow the following interfaces:
public interface IStamp {
double get_faceValue();
String get_name(); // return the name of a stamp
Int get_publicationYear(); //return the Publication year of a stamp
}
public interface IPhilatelist {
ArrayList get_allStamps();
void add_stamps(IStamp stmp);
double get_totalCommercialValue();
}
Your classes (Stamp_GroupI, Stamp_GroupII and Philatelist) implementing the above two interfaces, as appropriate, should NOT have any other public method.
The test file is as follows:
class Program {
static void Main(string[] args) {
IPhilatelist john = new Philatelist("John");
IStamp w1= new Stamp_GroupII("Yellow Stone",0.29, 1975);
IStamp w2 = new Stamp_GroupI("Forever Freedom",0.45, 2011);
IStamp w3 = new Stamp_GroupI("Forever BigBen",0.42, 2008);
john.add_stamps(w1);
john.add_stamps(w2);
john.add_stamps(w3);
System.out.println("Total Commercial value is" + john.get_totalCommercialValue());
}
}