Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
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
Alexey Utovka committed Apr 10, 2019
0 parents commit 1b7795d
Show file tree
Hide file tree
Showing 55 changed files with 2,236 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .gitignore
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
29 changes: 29 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 49 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/runConfigurations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
33 changes: 33 additions & 0 deletions app/build.gradle
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'
}
Binary file added app/proguard-rules.pro
Binary file not shown.
24 changes: 24 additions & 0 deletions app/src/main/AndroidManifest.xml
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>
Binary file added app/src/main/app_icon-web.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/application_icon-web.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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();
}
62 changes: 62 additions & 0 deletions app/src/main/java/ru/neurospb/calculator/core/models/Number.java
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;
}
}
Loading

0 comments on commit 1b7795d

Please sign in to comment.