Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .idea/appInsightsSettings.xml

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

10 changes: 10 additions & 0 deletions .idea/deploymentTargetDropDown.xml

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

5 changes: 2 additions & 3 deletions .idea/gradle.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/kotlinc.xml

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

10 changes: 10 additions & 0 deletions .idea/migrations.xml

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

1 change: 0 additions & 1 deletion .idea/misc.xml

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

33 changes: 23 additions & 10 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,37 +1,50 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
compileSdkVersion 34

defaultConfig {
applicationId "com.example.algorithmstudy"
minSdkVersion 21
targetSdkVersion 29
targetSdkVersion 34
versionCode 1
versionName "1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildFeatures {
viewBinding = true
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
namespace 'com.example.algorithmstudy'

compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_17.toString()
}
kotlin {
jvmToolchain(17)
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.core:core-ktx:1.12.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}
7 changes: 4 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.algorithmstudy">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<application
android:allowBackup="true"
Expand All @@ -9,7 +8,9 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.example.algorithmstudy.pattern.creation.abstractfactory

interface Building<in UnitType, out ProducedUnit>
where UnitType : Enum<*>, ProducedUnit : Unit {
where UnitType : Enum<*>, ProducedUnit : GameUnit {

fun build(type: UnitType): ProducedUnit
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.algorithmstudy.pattern.creation.abstractfactory

interface Unit {
interface GameUnit {
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.algorithmstudy.pattern.creation.abstractfactory

interface Infantry : Unit {
interface Infantry : GameUnit {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.example.algorithmstudy.pattern.creation.abstractfactory

enum class MechanicUnits {
VULTURE,
SIEGE_TANK
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.algorithmstudy.pattern.creation.abstractfactory

interface Vehicle : Unit {
interface Mechanics : GameUnit {
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.example.algorithmstudy.pattern.creation.abstractfactory

import com.example.algorithmstudy.pattern.creation.abstractfactory.buildings.Barracks

class HQ {
private val buildings = mutableListOf<Building<*, Unit>>()
private val buildings = mutableListOf<Building<*, GameUnit>>()

fun buildBarracks(): Barracks {
val b = Barracks()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.example.algorithmstudy.pattern.creation.abstractfactory.buildings

import com.example.algorithmstudy.pattern.creation.abstractfactory.Building
import com.example.algorithmstudy.pattern.creation.abstractfactory.InfantryUnits
import com.example.algorithmstudy.pattern.creation.abstractfactory.GameUnit
import com.example.algorithmstudy.pattern.creation.abstractfactory.units.infantry.Rifleman
import com.example.algorithmstudy.pattern.creation.abstractfactory.units.infantry.RocketSoldier


class Barracks : Building<InfantryUnits, GameUnit> {
override fun build(type: InfantryUnits): GameUnit {
return when (type) {
InfantryUnits.RIFLEMAN -> Rifleman()
InfantryUnits.ROCKET_SOLDIER -> RocketSoldier()
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.example.algorithmstudy.pattern.creation.abstractfactory.buildings

import com.example.algorithmstudy.pattern.creation.abstractfactory.Building
import com.example.algorithmstudy.pattern.creation.abstractfactory.MechanicUnits
import com.example.algorithmstudy.pattern.creation.abstractfactory.GameUnit
import com.example.algorithmstudy.pattern.creation.abstractfactory.units.mechanics.SiegeTank
import com.example.algorithmstudy.pattern.creation.abstractfactory.units.mechanics.Vulture


class Factory : Building<MechanicUnits, GameUnit> {

override fun build(type: MechanicUnits): GameUnit {
return when (type) {
MechanicUnits.VULTURE -> Vulture()
MechanicUnits.SIEGE_TANK -> SiegeTank()
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.algorithmstudy.pattern.creation.abstractfactory.units
package com.example.algorithmstudy.pattern.creation.abstractfactory.units.infantry

import com.example.algorithmstudy.pattern.creation.abstractfactory.Infantry

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.algorithmstudy.pattern.creation.abstractfactory.units
package com.example.algorithmstudy.pattern.creation.abstractfactory.units.infantry

import com.example.algorithmstudy.pattern.creation.abstractfactory.Infantry

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.example.algorithmstudy.pattern.creation.abstractfactory.units.mechanics

import com.example.algorithmstudy.pattern.creation.abstractfactory.Mechanics

class SiegeTank : Mechanics {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.example.algorithmstudy.pattern.creation.abstractfactory.units.mechanics

import com.example.algorithmstudy.pattern.creation.abstractfactory.Mechanics

class Vulture : Mechanics {

}
12 changes: 6 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.3.72'
ext.kotlin_version = '1.9.10'
repositories {
google()
jcenter()

mavenCentral()
gradlePluginPortal()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
classpath 'com.android.tools.build:gradle:8.2.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

// NOTE: Do not place your application dependencies here; they belong
Expand All @@ -19,8 +19,8 @@ buildscript {
allprojects {
repositories {
google()
jcenter()

mavenCentral()
gradlePluginPortal()
}
}

Expand Down
3 changes: 3 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ android.useAndroidX=true
android.enableJetifier=true
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official
android.defaults.buildfeatures.buildconfig=true
android.nonTransitiveRClass=false
android.nonFinalResIds=false
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists