Here is an example of how you can write the Java program and classes according to the requirements:
Task 1:
public class HardDrive {
private double price;
public HardDrive(double price) {
this.price = price;
}
public double getPrice() {
return price;
}
}
public class CompactHardDrive {
private double price;
public CompactHardDrive(double price) {
this.price = price;
}
public double getPrice() {
return price;
}
}
public class LargeCapacityHardDrive {
private double price;
public LargeCapacityHardDrive(double price) {
this.price = price;
}
public double getPrice() {
return price;
}
}
public class SSD {
private double price;
public SSD(double price) {
this.price = price;
}
public double getPrice() {
return price;
}
}
public class LargeCapacitySSD {
private double price;
public LargeCapacitySSD(double price) {
this.price = price;
}
public double getPrice() {
return price;
}
}
public class MemoryModule {
private double price;
public MemoryModule(double price) {
this.price = price;
}
public double getPrice() {
return price;
}
}
public class Ram16GB extends MemoryModule {
public Ram16GB(double price) {
super(price);
}
}
public class Ram32GB extends MemoryModule {
public Ram32GB(double price) {
super(price);
}
}
public class Processor {
private double price;
public Processor(double price) {
this.price = price;
}
public double getPrice() {
return price;
}
}
public class EfficientProcessor extends Processor {
public EfficientProcessor(double price) {
super(price);
}
}
public class PowerfulProcessor extends Processor {
public PowerfulProcessor(double price) {
super(price);
}
}
public class TestTask1 {
public static void main(String[] args) {
HardDrive hardDrive = new HardDrive(75.0);
CompactHardDrive compactHardDrive = new CompactHardDrive(64.0);
LargeCapacityHardDrive largeCapacityHardDrive = new LargeCapacityHardDrive(130.0);
SSD ssd = new SSD(80.0);
LargeCapacitySSD largeCapacitySSD = new LargeCapacitySSD(120.0);
Ram16GB ram16GB = new Ram16GB(40.0);
Ram32GB ram32GB = new Ram32GB(69.0);
EfficientProcessor efficientProcessor = new EfficientProcessor(306.0);
PowerfulProcessor powerfulProcessor = new PowerfulProcessor(589.0);
System.out.println("Hard Drive $" + hardDrive.getPrice());
System.out.println("Compact Hard Drive $" + compactHardDrive.getPrice());
System.out.println("Large Capacity Hard Drive $" + largeCapacityHardDrive.getPrice());
System.out.println("SSD $" + ssd.getPrice());
System.out.println("Large Capacity SSD $" + largeCapacitySSD.getPrice());
System.out.println("16GB Memory Module (Ram16GB) $" + ram16GB.getPrice());
System.out.println("32GB Memory Module (Ram32GB) $" + ram32GB.getPrice());
System.out.println("Efficient Processor $" + efficientProcessor.getPrice());
System.out.println("Powerful Processor $" + powerfulProcessor.getPrice());
}
}
Task 2:
public class HardDrive {
private double price;
private int totalNumOfPlatter;
public HardDrive(double price, int totalNumOfPlatter) {
this.price = price;
this.totalNumOfPlatter = totalNumOfPlatter;
}
public double getPrice() {
return price;
}
public int getTotalNumOfPlatter() {
return totalNumOfPlatter;
}
}
public class CompactHardDrive extends HardDrive {
public CompactHardDrive(double price, int totalNumOfPlatter) {
super(price, totalNumOfPlatter);
}
}
public class LargeCapacityHardDrive extends HardDrive {
public LargeCapacityHardDrive(double price, int totalNumOfPlatter) {
super(price, totalNumOfPlatter);
}
}
public class SSD {
private double price;
public SSD(double price) {
this.price = price;
}
public double getPrice() {
return price;
}
}
public class LargeCapacitySSD extends SSD {
public LargeCapacitySSD(double price) {
super(price);
}
}
public class MemoryModule {
private double price;
public MemoryModule(double price) {
this.price = price;
}
public double getPrice() {
return price;
}
}
public class Ram16GB extends MemoryModule {
public Ram16GB(double price) {
super(price);
}
}
public class Ram32GB extends MemoryModule {
public Ram32GB(double price) {
super(price);
}
}
public class Processor {
private double price;
public Processor(double price) {
this.price = price;
}
public double getPrice() {
return price;
}
}
public class EfficientProcessor extends Processor {
public EfficientProcessor(double price) {
super(price);
}
}
public class PowerfulProcessor extends Processor {
public PowerfulProcessor(double price) {
super(price);
}
}
public class TestTask2 {
public static void main(String[] args) {
CompactHardDrive compactHardDrive1 = new CompactHardDrive(64.0, 2);
CompactHardDrive compactHardDrive2 = new CompactHardDrive(64.0, 3);
LargeCapacityHardDrive largeCapacityHardDrive1 = new LargeCapacityHardDrive(130.0, 4);
LargeCapacityHardDrive largeCapacityHardDrive2 = new LargeCapacityHardDrive(130.0, 5);
SSD ssd1 = new SSD(80.0);
SSD ssd2 = new SSD(80.0);
LargeCapacitySSD largeCapacitySSD1 = new LargeCapacitySSD(120.0);
LargeCapacitySSD largeCapacitySSD2 = new LargeCapacitySSD(120.0);
Ram16GB ram16GB1 = new Ram16GB(40.0);
Ram16GB ram16GB2 = new Ram16GB(40.0);
Ram32GB ram32GB1 = new Ram32GB(69.0);
Ram32GB ram32GB2 = new Ram32GB(69.0);
EfficientProcessor efficientProcessor1 = new EfficientProcessor(306.0);
EfficientProcessor efficientProcessor2 = new EfficientProcessor(306.0);
PowerfulProcessor powerfulProcessor1 = new PowerfulProcessor(589.0);
PowerfulProcessor powerfulProcessor2 = new PowerfulProcessor(589.0);
int totalNumOfPlatter = compactHardDrive1.getTotalNumOfPlatter() + compactHardDrive2.getTotalNumOfPlatter() + largeCapacityHardDrive1.getTotalNumOfPlatter()
+ largeCapacityHardDrive2.getTotalNumOfPlatter();
System.out.println("Total Number of Platters: " + totalNumOfPlatter);
}
}
Task 3:
public class HardDrive {
private double price;
public HardDrive(double price) {
this.price = price;
}
public double getPrice() {
return price;
}
}
public class CompactHardDrive extends HardDrive {
public CompactHardDrive(double price) {
super(price);
}
}
public class LargeCapacityHardDrive extends HardDrive {
public LargeCapacityHardDrive(double price) {
super(price);
}
}
public class SSD {
private double price;
public SSD(double price) {
this.price = price;
}
public double getPrice() {
return price;
}
}
public class LargeCapacitySSD extends SSD {
public LargeCapacitySSD(double price) {
super(price);
}
}
public class MemoryModule {
private double price;
public MemoryModule(double price) {
this.price = price;
}
public double getPrice() {
return price;
}
}
public class Ram16GB extends MemoryModule {
public Ram16GB(double price) {
super(price);
}
}
public class Ram32GB extends MemoryModule {
public Ram32GB(double price) {
super(price);
}
}
public class Processor {
private double price;
public Processor(double price) {
this.price = price;
}
public double getPrice() {
return price;
}
}
public class EfficientProcessor extends Processor {
public EfficientProcessor(double price) {
super(price);
}
}
public class PowerfulProcessor extends Processor {
public PowerfulProcessor(double price) {
super(price);
}
}
public class ProductPackage {
private HardDrive storage;
private MemoryModule memory;
private Processor processor;
public ProductPackage(HardDrive storage, MemoryModule memory, Processor processor) {
this.storage = storage;
this.memory = memory;
this.processor = processor;
}
public double getPrice() {
double storagePrice = storage.getPrice() * 0.5;
double memoryPrice = memory.getPrice() * 0.45;
double processorPrice = processor.getPrice() * 0.9;
return storagePrice + memoryPrice + processorPrice;
}
}
public class TestTask3 {
public static void main(String[] args) {
SSD ssd = new SSD(80.0);
Ram16GB ram16GB = new Ram16GB(40.0);
EfficientProcessor efficientProcessor = new EfficientProcessor(306.0);
ProductPackage packageA = new ProductPackage(ssd, ram16GB, efficientProcessor);
System.out.println("Package A price: $" + packageA.getPrice());
LargeCapacityHardDrive largeCapacityHardDrive = new LargeCapacityHardDrive(130.0);
Ram32GB ram32GB = new Ram32GB(69.0);
PowerfulProcessor powerfulProcessor = new PowerfulProcessor(589.0);
ProductPackage packageB = new ProductPackage(largeCapacityHardDrive, ram32GB, powerfulProcessor);
System.out.println("Package B price: $" + packageB.getPrice());
}
}
This is just an example implementation and you may need to modify it based on your specific requirements.