Skip to content

Instantly share code, notes, and snippets.

@ivalexandru
ivalexandru / css_animations_beatingHeart.html
Created August 4, 2018 13:26
css_animations_beatingHeart.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<link rel="stylesheet" href="styles.css">
<!-- back e doar culoarea din fundal -->
@ivalexandru
ivalexandru / css_animatii_bounceBall.html
Created August 4, 2018 13:11
css_animatii_bounceBall
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<link rel="stylesheet" href="styles.css">
<style>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<link rel="stylesheet" href="styles.css">
<style>
#ball {
@ivalexandru
ivalexandru / Kotlin_functii_compacte2.kt
Last active June 1, 2018 08:41
Kotlin_functii_compacte2 (user inputs text to be used as a function parameter)
package quizzz
fun main(args: Array<String>) {
println(isVeryHot(36)) //true
// println(whatShouldIDoToday("happy", "sunny"))
// println(whatShouldIDoToday("sad"))
print("How do you feel?")
println(whatShouldIDoToday(readLine()!!))
}
@ivalexandru
ivalexandru / Kotlin_functii_compacte.kt
Created June 1, 2018 07:28
Kotlin_functii_compacte
fun main(args: Array<String>) {
println(shouldChangeWater("Friday"))
}
fun getDirtySensorReading() = 20
//acum, jos in functia shouldChangeWater inlocuiesc 20-ul cu functia asta, iar cand se va schimba functia asta(valoarea parametrii etc), in functia mare nu mai modific nimic
fun shouldChangeWater(
day: String,
@ivalexandru
ivalexandru / FitMoreFish.kt
Created May 31, 2018 16:38
FitMoreFish.kt
//cerinta exercitiului era:
//Exercise: Fit More Fish
//Create a function that checks if we can add another fish into a tank that already has fish in it.
//How many fish in a tank?
//
//The most widely known rule for stocking a tank is the one-inch-per-fish-per-gallon-of-water rule. However that's assuming the tank doesn't have any decorations in it.
//
//Typically, a tank with decorations can contain a total length of fish (in inches) less than or equal to 80% of the tank size (in gallons). A tank without decorations can contain a total length of fish up to 100% of the tank size.
//For example:
//
@ivalexandru
ivalexandru / Kotlin_Null_Safety.kt
Created May 30, 2018 04:24
Kotlin_Null_Safety.kt
package academy.learnprogramming.calculator
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.widget.EditText
import android.widget.TextView
class MainActivity : AppCompatActivity() {
//varianta1
//we tell kotlin that we're using a non-nullable variable, but that we'll delay giving it a value until later
@ivalexandru
ivalexandru / Kotlin_fortuneCookie.kt
Created May 29, 2018 15:23
Kotlin_fortuneCookie.kt
//Create a function called getBirthday() that gets the birthday from the user.
//Pass the result of getBirthday() to getFortune() using an Integer argument, and use it to return the correct fortune.
//Remove getting the birthday from getFortune()
//Instead of calculating the fortune based on the birthday, use a when statement to assign some fortunes as follows (or use your own conditions):
//
//Hint: There are several ways in which to make this when statement. How much can you Kotlinize it?
//
//Starter Code:
fun main(args: Array<String>) {
@ivalexandru
ivalexandru / Kotlin_functions_feedTheFish.kt
Created May 29, 2018 15:22
Kotlin_functions_feedTheFish.kt
import java.util.*
fun main(args: Array<String>) {
println("Hello, ${args[0]}!")
feedTheFish()
}
fun feedTheFish(){
val day = randomDay() //we call the function here
val food = fishFood(day)
@ivalexandru
ivalexandru / Main.kt
Created May 29, 2018 03:37
Kotlin_Functions_lvl2.kt
import kotlin.math.pow
import java.util.*
fun main(args: Array<String>) {
//extra-practice:
//Use a for loop to run the program 10 times, or until the "Take it easy" fortune has been selected.
var fortune: String
for (i in 1..10) {
fortune = getFortune()
println("\nYour fortune is: $fortune")