Skip to content

moserc/kotlin-project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Alternative Language Project

Author: Cheryl Moser


Table of Contents

Chosen language and version: Kotlin v1.9.0

Inspired by my enthusiasm for Android technology.

Some Language features

  • object-oriented programming
    Kotlin uses classes, which can be instantiated as objects. Classes may have class functions. Kotlin supports subclasses and superclasses.

  • file ingestion
    Kotlin is derived from Java, and as such, there exists the ability to import java packages. For this project, I imported java.io.File and used its readLines() function. For example:

import java.io.File

fun main() {
    val fileName = <filename here>
    File(fileName).readLines()
    ...content here...
}
  • conditional statements
    Kotlin uses if, if-else, the 'is' operator, and 'when' expressions for conditional statements. For example:
//if and if-else #1
if (x > 5){
    <do something> //could stop here or continue with else
} else {
    <do something else>
}

//if-else #2
val result = if (x > 5) <do something> else <do something else>

//when
val x = 5
when (x){
    5 -> "yay x is 5!"
    6 -> "hey, x is not 5!"
    else -> "what is x, anyway?"
    
//is
val obj: Any = "I'm an object"
when(obj){
    is String -> "I'm a String object"
    is Int -> "I'm an Int object"
    else -> "I don't know what type of object I am"
  • assignment statements
    Kotlin supports the '=' assignment operator, as well as combination operators. These assignments include addition (+=), subtraction (-=), multiplication (*=), division (/=), and modulus (%=).

  • Loops
    Kotlin supports for-loops, while-loops, and do-while-loops.

  • subprograms (functions/methods)
    Subprograms are signalled by the 'fun' keyword. Subprograms can exist as part of a class, or they can exist in their own separate file, as long as they exist within the same package.

  • Unit testing and exception handling
    Typically, JUnit is imported to perform unit testing. Kotlin is interoperable with Java, which makes this convenient.
    Kotlin uses try-catch blocks, and try-catch-finally blocks for exception handling, as well as the keyword 'throw'.

Libraries used (up to 3, if any)

  • JUnit for unit testing
  • OpenJDK: corretto-17 for runtime environment
  • KotlinJavaRuntime: runtime and Java interoperability component

Answer the following questions

What company (oem) has the highest average weight of the phone body?

Was there any phones that were announced in one year and released in another? What are they? Give me the oem and models.

How many phones have only one feature sensor?

What year had the most phones launched in any year later than 1999?

About

New language exploration

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages