class PaymentService {
private let _database: Database
init(database: Database) {
_database = database
}
func paymentIsValid() {
// Implementation code
}
func openDatabase() {
// Implementation code
}
func addNewPayment() {
// Implementation code
}
func removePaymentByID() {
// Implementation code
}
func updatePaymentByID() {
// Implementation code
}
}
protocol Database {
func insert()
func update()
func delete()
}
class MySQLDatabase : Database {
func insert() {
// Implementation code
}
func update() {
// Implementation code
}
func delete() {
// Implementation code
}
}
class MongoDatabase : Database {
func insert() {
// Implementation code
}
func update() {
// Implementation code
}
func delete() {
// Implementation code
}
}