Skip to content
Permalink
Browse files

Edit constructor. D for SOLID principle #2

  • Loading branch information...
Danil42Russia committed Apr 19, 2019
1 parent 14cdf79 commit 0fa14bf6543d97de3e684b57e6de18ce83792c23
Showing with 6 additions and 6 deletions.
  1. +4 −2 src/ru/danil42russia/aaa/Main.kt
  2. +2 −4 src/ru/danil42russia/aaa/service/BusinessLogic.kt
@@ -4,11 +4,13 @@ import ru.danil42russia.aaa.domain.ExitCode
import ru.danil42russia.aaa.domain.User
import ru.danil42russia.aaa.service.BusinessLogic
import ru.danil42russia.aaa.service.CmdService
import ru.danil42russia.aaa.service.UserService
import kotlin.system.exitProcess

fun main(args: Array<String>) {
val cmdService = CmdService()
val businessLogic = BusinessLogic()
val userService = UserService()

val users = listOf(
User(
@@ -25,10 +27,10 @@ fun main(args: Array<String>) {

val cmd = cmdService.parse(args)

var exitCodes = businessLogic.authentication(cmd.login, cmd.help, cmdService)
var exitCodes = businessLogic.authentication(cmd.login, cmd.help, cmdService, userService)

if (exitCodes == ExitCode.SUCCESS) {
exitCodes = businessLogic.authorization(cmd.login, cmd.pass, users)
exitCodes = businessLogic.authorization(cmd.login, cmd.pass, userService, users)
}

if (exitCodes == ExitCode.SUCCESS) {
@@ -6,8 +6,7 @@ import ru.danil42russia.aaa.domain.User

class BusinessLogic {
//0,1,2
fun authentication(login: String, help: Boolean, cmd: CmdService): ExitCode {
val userService = UserService()
fun authentication(login: String, help: Boolean, cmd: CmdService, userService: UserService): ExitCode {
var isEditCode = false
var exitCodes: ExitCode = ExitCode.SUCCESS

@@ -25,8 +24,7 @@ class BusinessLogic {
}

//0,3,4
fun authorization(login: String, pass: String, users: List<User>): ExitCode {
val userService = UserService()
fun authorization(login: String, pass: String, userService: UserService, users: List<User>): ExitCode {
var exitCodes: ExitCode = ExitCode.SUCCESS

val user = userService.findUserByLogin(login, users)

0 comments on commit 0fa14bf

Please sign in to comment.
You can’t perform that action at this time.