-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
226 additions
and
12 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
MyUnitTest/app/src/main/java/com/siaptekno/myunittest/CuboidModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,23 @@ | ||
package com.siaptekno.myunittest | ||
|
||
class CuboidModel { | ||
private var width = 0.0 | ||
private var length = 0.0 | ||
private var height = 0.0 | ||
|
||
fun getVolume(): Double = width * length * height | ||
|
||
fun getSurfaceArea(): Double { | ||
val wl = width * length | ||
val wh = width * height | ||
val lh = length * height | ||
return 2 * (wl + wh + lh) | ||
} | ||
|
||
fun getCircumference(): Double = 4 * (width + length + height) | ||
fun save(width: Double, length: Double, height: Double) { | ||
this.width = width | ||
this.length = length | ||
this.height = height | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 7 additions & 1 deletion
8
MyUnitTest/app/src/main/java/com/siaptekno/myunittest/MainViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,10 @@ | ||
package com.siaptekno.myunittest | ||
|
||
class MainViewModel { | ||
class MainViewModel(private val cuboidModel: CuboidModel) { | ||
fun getCircumference() = cuboidModel.getCircumference() | ||
fun getSurfaceArea() = cuboidModel.getSurfaceArea() | ||
fun getVolume() = cuboidModel.getVolume() | ||
fun save(w: Double, l: Double, h: Double) { | ||
cuboidModel.save(w, l, h) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,88 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:id="@+id/main" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:orientation="vertical" | ||
android:padding="16dp" | ||
tools:context=".MainActivity"> | ||
|
||
<TextView | ||
android:layout_width="wrap_content" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:text="Hello World!" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
android:text="@string/length" /> | ||
<EditText | ||
android:id="@+id/edt_length" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginBottom="16dp" | ||
android:inputType="numberDecimal" | ||
android:lines="1" /> | ||
<TextView | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:text="@string/width" /> | ||
<EditText | ||
android:id="@+id/edt_width" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginBottom="16dp" | ||
android:inputType="numberDecimal" | ||
android:lines="1" /> | ||
<TextView | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:text="@string/height" /> | ||
<EditText | ||
android:id="@+id/edt_height" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginBottom="16dp" | ||
android:inputType="numberDecimal" | ||
android:lines="1" /> | ||
<Button | ||
android:id="@+id/btn_save" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:text="@string/save" /> | ||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginBottom="16dp" | ||
android:orientation="horizontal"> | ||
<Button | ||
android:id="@+id/btn_calculate_volume" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_weight="1" | ||
android:text="@string/calculate_volume" | ||
android:visibility="gone" /> | ||
<Button | ||
android:id="@+id/btn_calculate_circumference" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_weight="1" | ||
android:layout_marginStart="8dp" | ||
android:layout_marginEnd="8dp" | ||
android:text="@string/calculate_circumference" | ||
android:visibility="gone" /> | ||
<Button | ||
android:id="@+id/btn_calculate_surface_area" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_weight="1" | ||
android:text="@string/calculate_surface_area" | ||
android:visibility="gone" /> | ||
</LinearLayout> | ||
<TextView | ||
android:id="@+id/tv_result" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginBottom="16dp" | ||
android:gravity="center" | ||
android:text="@string/result" | ||
android:textSize="24sp" | ||
android:textStyle="bold" /> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> | ||
</LinearLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,12 @@ | ||
<resources> | ||
<string name="app_name">MyUnitTest</string> | ||
|
||
<string name="width">Lebar</string> | ||
<string name="result">Hasil</string> | ||
<string name="calculate_volume">Hitung Volume</string> | ||
<string name="calculate_surface_area">Hitung Luas Area</string> | ||
<string name="calculate_circumference">Hitung Keliling</string> | ||
<string name="height">Tinggi</string> | ||
<string name="length">Panjang</string> | ||
<string name="save">Simpan</string> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters