You need to create apex interfaces and abstract classes and call them from the main class https://www.tutorialspoint.com/apex/apex_interfaces.htm
// Interface
public interface DiscountProcessor {
Double percentageDiscountTobeApplied(); // method signature only
}
// Premium Customer Class
public class PremiumCustomer implements DiscountProcessor {
//Method Call
public Double percentageDiscountTobeApplied () {
// For Premium customer, discount should be 30%
return 0.30;
}
}
// Normal Customer Class
public class NormalCustomer implements DiscountProcessor {
// Method Call
public Double percentageDiscountTobeApplied () {
// For Premium customer, discount should be 10%
return 0.10;
}
}
You need to create apex interfaces and abstract classes and call them from the main class
https://www.tutorialspoint.com/apex/apex_interfaces.htm