abstract class Publication {
int numberOfAuthors;
public Publication(int numberOfAuthors) {
this.numberOfAuthors = numberOfAuthors;
}
public abstract double computeScore();
}
class Journal extends Publication {
double impactFactor;
public Journal(int numberOfAuthors, double impactFactor) {
super(numberOfAuthors);
this.impactFactor = impactFactor;
}
@Override
public double computeScore() {
return (impactFactor * 0.5) / numberOfAuthors;
}
}
class ConferenceProceeding extends Publication {
boolean isIndexed;
public ConferenceProceeding(int numberOfAuthors, boolean isIndexed) {
super(numberOfAuthors);
this.isIndexed = isIndexed;
}
@Override
public double computeScore() {
return isIndexed ? 0.25 / numberOfAuthors : 0.2 / numberOfAuthors;
}
}
class Author {
java.util.List<Publication> publications = new java.util.ArrayList<>();
this.name = name;
}
public void addPublication(Publication pub) {
publications.add(pub);
}
public double computeScore() {
double total = 0;
for (Publication pub : publications) {
total += pub.computeScore();
}
return total;
}
}
class University {
java.util.List<Author> authors = new java.util.ArrayList<>();
public void addAuthor(Author author) {
authors.add(author);
}
public double computeScore() {
double total = 0;
for (Author author : authors) {
total += author.computeScore();
}
return total;
}
}
public class Main {
public static void main
(String[] args
) { Journal journal1 = new Journal(3, 2.5);
Journal journal2 = new Journal(4, 3.0);
ConferenceProceeding conf1 = new ConferenceProceeding(2, true);
ConferenceProceeding conf2 = new ConferenceProceeding(5, false);
Author author1 = new Author("Alice");
Author author2 = new Author("Bob");
author1.addPublication(journal1);
author1.addPublication(journal2);
author1.addPublication(conf1);
author1.addPublication(conf2);
author2.addPublication(journal1);
author2.addPublication(journal2);
author2.addPublication(conf1);
author2.addPublication(conf2);
University university = new University();
university.addAuthor(author1);
university.addAuthor(author2);
System.
out.
println("Score of Author 1: " + author1.
computeScore()); System.
out.
println("Score of Author 2: " + author2.
computeScore()); System.
out.
println("Total score of the University: " + university.
computeScore()); }
}