Skip to content

Commit

Permalink
[Basic] Task 5 Creating Classes (#10)
Browse files Browse the repository at this point in the history
* basics 5 and test

* Changes made after review

* Added description about the class

* Edited line no.07 from Basics05 to Basics05Solution
  • Loading branch information
Sonal3274 committed Dec 5, 2022
1 parent c4f7701 commit a7fba97
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 0 deletions.
12 changes: 12 additions & 0 deletions basics/src/main/kotlin/de/thermondo/basics/Basics05.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package de.thermondo.basics

/**
* Use the `class` keyword to define a class.
* Class naming is done in upper camel case.
*
* Create a class named Basics05
*
* Define member variables:
* name: String
* age: Int
*/
25 changes: 25 additions & 0 deletions basics/src/test/kotlin/de/thermondo/basics/Basics5Test.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package de.thermondo.basics

import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertNotNull

class Basics5Test {

private val clazz = Basics5()

@Test
fun `Validate that class exists`() {
assertNotNull(clazz)
}

@Test
fun `Validate name is Kotlin`() {
assertEquals(expected = "Kotlin", actual = clazz.name)
}

@Test
fun `Validate age is 26`() {
assertEquals(expected = 26, actual = clazz.age)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package de.thermondo.solutions.basics

/**
* Use the `class` keyword to define a class.
* Class naming is done in upper camel case.
*
* Create a class named Basics05Solution
*
* Define member variables:
* name: String
* age: Int
*/

@Suppress("MagicNumber")
class Basics05Solution {
val name: String = "Kotlin"
val age: Int = 26
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package de.thermondo.solutions.basics

import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertNotNull

class Basics05SolutionTest {

private val clazz = Basics05Solution()

@Test
fun `Validate that class exists`() {
assertNotNull(clazz)
}

@Test
fun `Validate name is Kotlin`() {
assertEquals(expected = "Kotlin", actual = clazz.name)
}

@Test
fun `Validate age is 26`() {
assertEquals(expected = 26, actual = clazz.age)
}
}

0 comments on commit a7fba97

Please sign in to comment.