Skip to content
Open
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
1 change: 1 addition & 0 deletions .idea/gradle.xml

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

24 changes: 24 additions & 0 deletions app/src/main/java/com/example/androidpractice2020/ExpHeir.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.example.androidpractice2020

class ExpHeir : Experience(19, 179), SomeMethods {
private var name: String = "Danil"
var flag: Boolean = false
set(value) {
field = value
}

override fun max(number1: Int, number2: Int): String {

Choose a reason for hiding this comment

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

мог написать через равно, без ретерна:
override fun max(number1: Int, number2: Int): String = when {}

return when {
number1 < number2 -> ("Минимальное число - $number1")
else -> ("Минимальное число - $number2")
}
}

override fun stringUpper(str1 : String) : String {
return(str1.toUpperCase())
}

override fun stringLower(str2 : String) : String {
return (str2.toLowerCase())
}
}
28 changes: 28 additions & 0 deletions app/src/main/java/com/example/androidpractice2020/Experience.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.example.androidpractice2020

open class Experience(var age: Int, var height: Int) {
private var i: Int = 0
init {
var sum = age + height
}
var mail: String = ""
private var password: String = ""
fun mai(mail: String) {
print(mail)
}
open fun max(number1: Int, number2: Int): String {
return when {
number1 > number2 -> ("Максимальное число - $number1")
else -> ("Максимальное число - $number2")
}
}
fun cycle() : String {
var mass = emptyArray<String>()
for (i in 0..10) {
mass[i] = "$i"
}
if (mass[0] == "0")
return "cool"
return "not cool"
}
}
15 changes: 15 additions & 0 deletions app/src/main/java/com/example/androidpractice2020/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,25 @@ package com.example.androidpractice2020

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.TextView

class MainActivity : AppCompatActivity() {
private var message1: TextView? = null
private var message2: TextView? = null
private var message3: TextView? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val nameStudent = User("Danil", 19, "KFU")
val email = Experience(19, 171).mai("stud@kpfu")
val exp = Experience(19, 170)
message1 = findViewById(R.id.setMessage)
message1?.text = exp.max(1, 12)
val str = ExpHeir()
message2 = findViewById(R.id.setMessage2)
message2?.text = str.stringUpper("android the best")
val exp2 = Experience(19, 172)
// message3 = findViewById(R.id.setMessage4)
// message3?.text = exp2.cycle()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.example.androidpractice2020

interface SomeMethods {
fun stringUpper(str1 : String) : String
fun stringLower(str2 : String) : String
}
7 changes: 7 additions & 0 deletions app/src/main/java/com/example/androidpractice2020/User.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.example.androidpractice2020

data class User(
var name: String? = null,
var age: Int = 0,
var place: String? = null
)
69 changes: 59 additions & 10 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1,67 @@
<?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:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent"
tools:context=".MainActivity">
android:padding="10dp"
android:layout_width="match_parent">

<!-- <TextView-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:text="Hello World!"-->
<!-- app:layout_constraintBottom_toBottomOf="parent"-->
<!-- app:layout_constraintLeft_toLeftOf="parent"-->
<!-- app:layout_constraintRight_toRightOf="parent"-->
<!-- app:layout_constraintTop_toTopOf="parent" />-->

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Message1"
tools:layout_editor_absoluteX="14dp"
tools:layout_editor_absoluteY="39dp"
tools:ignore="MissingConstraints" />

<TextView
android:id="@+id/setMessage"
android:layout_width="match_parent"
android:layout_height="31dp"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="255dp"
tools:ignore="MissingConstraints" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
android:text="Message2"
tools:layout_editor_absoluteX="16dp"
tools:layout_editor_absoluteY="150dp"
tools:ignore="MissingConstraints" />

<TextView
android:id="@+id/setMessage2"
android:layout_width="match_parent"
android:layout_height="32dp"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="169dp"
tools:ignore="MissingConstraints" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Message3"
tools:layout_editor_absoluteX="16dp"
tools:layout_editor_absoluteY="236dp"
tools:ignore="MissingConstraints" />

<TextView
android:id="@+id/setMessage4"
android:layout_width="match_parent"
android:layout_height="29dp"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="58dp"
tools:ignore="MissingConstraints" />

</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>