-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
Simple string calculator based on Clean Architecture. Layers: *CORE >>> calculating string expression *UI >>> user input handling, calculation result handling Features: *simple arithmetic operations (addition, subtraction, multiplication, division) *unary subtraction *operation's priority assignment
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea/caches | ||
/.idea/libraries | ||
/.idea/modules.xml | ||
/.idea/workspace.xml | ||
/.idea/navEditor.xml | ||
/.idea/assetWizardSettings.xml | ||
.DS_Store | ||
/build | ||
/captures | ||
.externalNativeBuild |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
apply plugin: 'com.android.application' | ||
|
||
android { | ||
compileSdkVersion 28 | ||
buildToolsVersion '28.0.3' | ||
defaultConfig { | ||
applicationId "ru.neurospb.app_icon" | ||
minSdkVersion 15 | ||
targetSdkVersion 28 | ||
versionCode 1 | ||
versionName "1.0" | ||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation fileTree(dir: 'libs', include: ['*.jar']) | ||
implementation 'com.android.support:appcompat-v7:28.0.0' | ||
testImplementation 'junit:junit:4.12' | ||
androidTestImplementation 'com.android.support.test:runner:1.0.2' | ||
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' | ||
//V7 support libs | ||
implementation 'com.android.support:appcompat-v7:28.0.0' | ||
implementation 'com.android.support.constraint:constraint-layout:1.1.3' | ||
//material design support lib | ||
implementation 'com.android.support:design:28.0.0' | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<manifest | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
package="ru.neurospb.calculator"> | ||
|
||
<application | ||
android:allowBackup="false" | ||
android:icon="@mipmap/app_icon" | ||
android:label="@string/app_name" | ||
android:supportsRtl="true" | ||
android:theme="@style/AppTheme" | ||
tools:ignore="GoogleAppIndexingWarning"> | ||
|
||
<activity | ||
android:name=".ui.views.base.StartPointActivity" | ||
android:launchMode="singleInstance"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
|
||
</application> | ||
</manifest> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package ru.neurospb.calculator.core.gateways; | ||
|
||
/** | ||
* GATEWAY for UI layer | ||
* Функционал для получателя(обработчика) результата выполнения действий системы (use case) | ||
* | ||
* @author Алексей Утовка | ||
* @version а1 | ||
*/ | ||
|
||
public interface IUIResultHandler { | ||
//обратный вызов для передачи результата Действия в слой UI | ||
void onResult(String result); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package ru.neurospb.calculator.core.models; | ||
|
||
/** | ||
* Базовый функционал для математических единиц. | ||
* | ||
* @author Алексей Утовка | ||
* @version а1 | ||
*/ | ||
|
||
public interface IMathUnit { | ||
//возвращает тип математической единицы | ||
int getType(); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package ru.neurospb.calculator.core.models; | ||
|
||
/** | ||
* Model. | ||
* Модель числа | ||
* | ||
* @author Алексей Утовка | ||
* @version а1 | ||
*/ | ||
|
||
public class Number implements IMathUnit{ | ||
private double value; | ||
|
||
public static final int TYPE_NUMBER = 20; | ||
private static final char CHAR_0 = '0'; | ||
private static final char CHAR_1 = '1'; | ||
private static final char CHAR_2 = '2'; | ||
private static final char CHAR_3 = '3'; | ||
private static final char CHAR_4 = '4'; | ||
private static final char CHAR_5 = '5'; | ||
private static final char CHAR_6 = '6'; | ||
private static final char CHAR_7 = '7'; | ||
private static final char CHAR_8 = '8'; | ||
private static final char CHAR_9 = '9'; | ||
private static final char CHAR_POINT = '.'; | ||
private static final char CHAR_EXPONENT = 'E'; | ||
|
||
//КОНСТРУКТОР | ||
public Number(String stringValue) { | ||
value = Double.parseDouble(stringValue); | ||
} | ||
Number(double value) { | ||
this.value = value; | ||
} | ||
|
||
//ИМПЛЕМЕНТАЦИЯ: IMathUnit | ||
@Override | ||
public int getType() { | ||
return TYPE_NUMBER; | ||
} | ||
|
||
//МЕТОДЫ КЛАССА | ||
//GETTER: value | ||
public double getValue() { | ||
return value; | ||
} | ||
//Проверяет является ли символ частью числа | ||
public static boolean isNumberPart(char c) { | ||
return c == CHAR_0 || | ||
c == CHAR_1 || | ||
c == CHAR_2 || | ||
c == CHAR_3 || | ||
c == CHAR_4 || | ||
c == CHAR_5 || | ||
c == CHAR_6 || | ||
c == CHAR_7 || | ||
c == CHAR_8 || | ||
c == CHAR_9 || | ||
c == CHAR_POINT || | ||
c == CHAR_EXPONENT; | ||
} | ||
} |