Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Step1] 모듈 분리 #5

Merged
merged 2 commits into from
Aug 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions Domain/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
17 changes: 17 additions & 0 deletions Domain/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
plugins {
id 'java-library'
id 'kotlin'
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine:5.7.1' // junit4 지원
testImplementation 'org.junit.jupiter:junit-jupiter:5.7.1'
Comment on lines +13 to +14
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

junit5를 사용하려면 아래 코드도 설정해주셔야 합니다.

test {
    useJUnitPlatform()
}

testImplementation 'junit:junit:4.13.2'
testImplementation 'com.google.truth:truth:1.1.2'
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package edu.nextstep.camp.calculator.domain
package edu.nextstep.camp.domain

class Calculator {
fun calculate(rawExpression: String): Int? {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package edu.nextstep.camp.calculator.domain
package edu.nextstep.camp.domain

data class Expression(
private val values: List<Any> = emptyList()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package edu.nextstep.camp.calculator.domain
package edu.nextstep.camp.domain

enum class Operator(
val sign: String,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package edu.nextstep.camp.calculator.domain

import com.google.common.truth.Truth.assertThat
import edu.nextstep.camp.domain.Calculator
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package edu.nextstep.camp.calculator.domain

import com.google.common.truth.Truth.assertThat
import edu.nextstep.camp.domain.Expression
import edu.nextstep.camp.domain.Operator
import org.junit.jupiter.api.Test

class ExpressionTest {
Expand Down Expand Up @@ -67,7 +69,9 @@ class ExpressionTest {
@Test
fun `'32 + 1' 수식이 있을 때, 마지막 1을 제거할 수 있어야 한다`() {
// given
val expression = Expression(listOf(32, Operator.Plus, 1))
val expression = Expression(
listOf(32, Operator.Plus, 1)
)

// when
val actual = expression.removeLast()
Expand Down
2 changes: 2 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ dependencies {
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.0'

implementation project(':Domain')

testImplementation 'org.junit.jupiter:junit-jupiter:5.7.1'
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine:5.7.1' // junit4 지원
testImplementation 'junit:junit:4.13.2'
Expand Down
13 changes: 6 additions & 7 deletions app/src/main/java/edu/nextstep/camp/calculator/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ import android.os.Bundle
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import edu.nextstep.camp.calculator.databinding.ActivityMainBinding
import edu.nextstep.camp.calculator.domain.Calculator
import edu.nextstep.camp.calculator.domain.Expression
import edu.nextstep.camp.calculator.domain.Operator
import edu.nextstep.camp.domain.Calculator
import edu.nextstep.camp.domain.Expression

class MainActivity : AppCompatActivity() {
private lateinit var binding: ActivityMainBinding
Expand Down Expand Up @@ -59,19 +58,19 @@ class MainActivity : AppCompatActivity() {
binding.textView.text = expression.toString()
}
binding.buttonPlus.setOnClickListener {
expression += Operator.Plus
expression += edu.nextstep.camp.domain.Operator.Plus
binding.textView.text = expression.toString()
}
binding.buttonMinus.setOnClickListener {
expression += Operator.Minus
expression += edu.nextstep.camp.domain.Operator.Minus
binding.textView.text = expression.toString()
}
binding.buttonMultiply.setOnClickListener {
expression += Operator.Multiply
expression += edu.nextstep.camp.domain.Operator.Multiply
binding.textView.text = expression.toString()
}
binding.buttonDivide.setOnClickListener {
expression += Operator.Divide
expression += edu.nextstep.camp.domain.Operator.Divide
binding.textView.text = expression.toString()
}
binding.buttonDelete.setOnClickListener {
Expand Down
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
include ':app'
rootProject.name = "AndroidCalculator"
include ':Domain'