Advertisement
Guest User

Untitled

a guest
Jul 28th, 2014
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 1.03 KB | None | 0 0
  1. trait BaseMerchantProtocol {
  2.   protected def doCheck(transaction: BaseTransaction, requestParams: List[String]) = {
  3.     // some common code...
  4.     println(requestParams) // this one is specific-class-dependent
  5.     // ...and here is common code as well
  6.   }
  7.  
  8.   protected def requestParams(): List[String]
  9. }
  10.  
  11. class SmsCommerceMerchantProtocol(private val smsCommerceTransaction: SmsCommerceTransaction) extends BaseMerchantProtocol
  12. {
  13.   def check = {
  14.     doCheck(smsCommerceTransaction, requestParams())
  15.   }
  16.  
  17.   protected def requestParams() = {
  18.     List("result specific for SmsCommerceTransaction class")
  19.   }
  20. }
  21.  
  22. class TelepayMerchantProtocol(private val telepayTransaction: TelepayTransaction) extends BaseMerchantProtocol
  23. {
  24.   def check = {
  25.     doCheck(telepayTransaction, requestParams())
  26.   }
  27.  
  28.   protected def requestParams() = {
  29.     List("result specific for TelepayTransaction class")
  30.   }
  31. }
  32.  
  33.  
  34. trait BaseTransaction
  35. class SmsCommerceTransaction extends BaseTransaction
  36. class TelepayTransaction extends BaseTransaction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement