Kumite (ko͞omiˌtā) is the practice of taking techniques learned from Kata and applying them through the act of freestyle sparring.
You can create a new kumite by providing some initial code and optionally some test cases. From there other warriors can spar with you, by enhancing, refactoring and translating your code. There is no limit to how many warriors you can spar with.
A great use for kumite is to begin an idea for a kata as one. You can collaborate with other code warriors until you have it right, then you can convert it to a kata.
best solution
package solution import kotlin.test.assertEquals import org.junit.Test class TestExample { @Test fun multiply() { assertEquals(4, 4) } }
// You can test using JUnit or KotlinTest. JUnit is shown below// TODO: replace this example test with your own, this is just here to demonstrate usage.// TODO: replace with whatever your package is called- package solution
- import kotlin.test.assertEquals
- import org.junit.Test
- class TestExample {
- @Test
- fun multiply() {
- assertEquals(4, 4)
- }
- }
class Human { #name; #surname; #birthday; constructor ( name = 'Jhon', surname = 'Doe' , birthday = new Date().toISOString().split`T`[0]) { this.#name = name this.#surname = surname this.#birthday = birthday } get name () { return this.#name } get surname () { return this.#surname } set name ( newName = 'Jhon' ) { this.#name = newName } set surname ( newSurname = 'Doe' ) { this.#surname = newSurname } get birthday () { return this.#birthday } getAge () { return `I'm ${(new Date() - new Date(this.#birthday))/1000/60/60/24/365|0} years old` } greeting () { return `Hello, my name is ${this.#name} ${this.#surname}` } } class Worker extends Human { #totalDays = 0 #hoursPerWeek = 0 #profession; constructor( name, surname, profession = 'Developer' ){ super() super.name = name super.surname = surname this.#profession = profession } get profession () { return this.#profession } get stats () { return { totalDays: this.#totalDays, hoursPerWeek: this.#hoursPerWeek } } doWork (hours = 8) { if (!(this.#totalDays % 7) && this.#totalDays) this.#hoursPerWeek = hours this.#hoursPerWeek += hours this.#totalDays += 1 return this } changeProfession ( newProfession ) { if ( !newProfession ) throw Error('The profession was not transferred!') if ( typeof newProfession !== 'string' ) throw TypeError('Incorrect new profession type!') this.#profession = newProfession this.#hoursPerWeek = 0 this.#totalDays = 0 return this } }
- class Human {
- #name;
- #surname;
constructor ( name = 'Jhon', surname = 'Doe' ) {- #birthday;
- constructor ( name = 'Jhon', surname = 'Doe' , birthday = new Date().toISOString().split`T`[0]) {
- this.#name = name
- this.#surname = surname
- this.#birthday = birthday
- }
- get name () {
- return this.#name
- }
- get surname () {
- return this.#surname
- }
- set name ( newName = 'Jhon' ) {
- this.#name = newName
- }
- set surname ( newSurname = 'Doe' ) {
- this.#surname = newSurname
- }
- get birthday () {
- return this.#birthday
- }
- getAge () {
- return `I'm ${(new Date() - new Date(this.#birthday))/1000/60/60/24/365|0} years old`
- }
- greeting () {
- return `Hello, my name is ${this.#name} ${this.#surname}`
- }
- }
- class Worker extends Human {
- #totalDays = 0
- #hoursPerWeek = 0
- #profession;
- constructor( name, surname, profession = 'Developer' ){
- super()
- super.name = name
- super.surname = surname
- this.#profession = profession
- }
- get profession () {
- return this.#profession
- }
- get stats () {
- return {
- totalDays: this.#totalDays,
- hoursPerWeek: this.#hoursPerWeek
- }
- }
- doWork (hours = 8) {
- if (!(this.#totalDays % 7) && this.#totalDays)
- this.#hoursPerWeek = hours
- this.#hoursPerWeek += hours
- this.#totalDays += 1
- return this
- }
- changeProfession ( newProfession ) {
- if ( !newProfession ) throw Error('The profession was not transferred!')
- if ( typeof newProfession !== 'string' ) throw TypeError('Incorrect new profession type!')
- this.#profession = newProfession
- this.#hoursPerWeek = 0
- this.#totalDays = 0
- return this
- }
- }
const { config, assert, expect } = require('chai') config.truncateThreshold = 0 const user0 = new Human(), user1 = new Human( 'Anatoly', 'Wasserman', '1952-12-09' ), user2 = new Human( 'Vladimir', 'Zelensky', '1978-01-25' ) describe('Humans tests:', () => { it('Creation tests', () => { assert.strictEqual( user0.name, 'Jhon' ) assert.strictEqual( user0.surname, 'Doe' ) assert.strictEqual( user0.birthday, new Date().toISOString().split`T`[0] ) assert.strictEqual( user1.name, 'Anatoly' ) assert.strictEqual( user1.surname, 'Wasserman' ) assert.strictEqual( user1.birthday, '1952-12-09') assert.strictEqual( user2.name, 'Vladimir' ) assert.strictEqual( user2.surname, 'Zelensky' ) assert.strictEqual( user2.birthday, '1978-01-25' ) }) it('Methods tests', () => { assert.strictEqual( user0.greeting(), 'Hello, my name is Jhon Doe' ) assert.strictEqual( user0.getAge(), `I'm 0 years old` ) assert.strictEqual( user1.greeting(), 'Hello, my name is Anatoly Wasserman' ) assert.strictEqual( user1.getAge(), `I'm 69 years old` ) assert.strictEqual( user2.greeting(), 'Hello, my name is Vladimir Zelensky' ) assert.strictEqual( user2.getAge(), `I'm 44 years old` ) }) it('Mutation tests', () => { user0.name = 'Nils' assert.strictEqual( user0.name, 'Nils' ) assert.deepEqual( user0, {} ) user1.name = 'Albert' assert.strictEqual( user1.name, 'Albert' ) assert.deepEqual( user1, {} ) user2.name = 'Johann' assert.strictEqual( user2.name, 'Johann' ) assert.deepEqual( user2, {} ) }) }) const worker0 = new Worker('Nils', 'Bor', 'scientist'), worker1 = new Worker('Albert', 'Einstein','scientist'), worker2 = new Worker('Anatoly'), worker3 = new Worker('Vladimir', 'Zelensky', 'comedian') describe('Wokers tests', () => { it('Creation tests', () => { assert.strictEqual( worker0.name, 'Nils' ) assert.strictEqual( worker0.surname, 'Bor' ) assert.strictEqual( worker0.profession, 'scientist') assert.strictEqual( worker1.name, 'Albert' ) assert.strictEqual( worker1.surname, 'Einstein' ) assert.strictEqual( worker1.profession, 'scientist') }) it('Methods tests', () => { worker0.doWork() assert.deepEqual(worker0.stats,{totalDays:1,hoursPerWeek:8}) worker1.doWork().doWork(7).doWork(9).doWork(11).doWork(5) assert.deepEqual(worker1.stats,{totalDays:5,hoursPerWeek:40}) worker2.doWork().doWork().doWork().doWork().doWork().doWork().doWork().doWork().doWork() assert.deepEqual(worker2.stats,{totalDays:9,hoursPerWeek:24}) worker3.changeProfession('president') assert.strictEqual(worker3.profession, 'president') }) it('Error test', () => { let throwed = false, message, error try { worker0.changeProfession() } catch (err) { [error, message] = [err, err.message] } expect( error ).to.be.an.instanceof(Error, 'Throwed error should be instance of "Error" constructor!') assert.strictEqual( message, 'The profession was not transferred!' ) }) it('TypeError test', () => { let throwed = false, message, error try { worker1.changeProfession(1234) } catch (err) { [error, message] = [err, err.message] } expect( error ).to.be.an.instanceof(TypeError, 'Throwed error should be instance of "TypeError" constructor!') assert.strictEqual( message, 'Incorrect new profession type!' ) }) })
- const { config, assert, expect } = require('chai')
- config.truncateThreshold = 0
- const user0 = new Human(),
user1 = new Human('Anatoly', 'Wasserman'),user2 = new Human('Vladimir', 'Zelensky')- user1 = new Human( 'Anatoly', 'Wasserman', '1952-12-09' ),
- user2 = new Human( 'Vladimir', 'Zelensky', '1978-01-25' )
- describe('Humans tests:', () => {
- it('Creation tests', () => {
- assert.strictEqual( user0.name, 'Jhon' )
- assert.strictEqual( user0.surname, 'Doe' )
- assert.strictEqual( user0.birthday, new Date().toISOString().split`T`[0] )
- assert.strictEqual( user1.name, 'Anatoly' )
- assert.strictEqual( user1.surname, 'Wasserman' )
- assert.strictEqual( user1.birthday, '1952-12-09')
- assert.strictEqual( user2.name, 'Vladimir' )
- assert.strictEqual( user2.surname, 'Zelensky' )
- assert.strictEqual( user2.birthday, '1978-01-25' )
- })
- it('Methods tests', () => {
- assert.strictEqual( user0.greeting(), 'Hello, my name is Jhon Doe' )
- assert.strictEqual( user0.getAge(), `I'm 0 years old` )
- assert.strictEqual( user1.greeting(), 'Hello, my name is Anatoly Wasserman' )
- assert.strictEqual( user1.getAge(), `I'm 69 years old` )
- assert.strictEqual( user2.greeting(), 'Hello, my name is Vladimir Zelensky' )
- assert.strictEqual( user2.getAge(), `I'm 44 years old` )
- })
- it('Mutation tests', () => {
- user0.name = 'Nils'
- assert.strictEqual( user0.name, 'Nils' )
- assert.deepEqual( user0, {} )
- user1.name = 'Albert'
- assert.strictEqual( user1.name, 'Albert' )
- assert.deepEqual( user1, {} )
- user2.name = 'Johann'
- assert.strictEqual( user2.name, 'Johann' )
- assert.deepEqual( user2, {} )
- })
- })
- const worker0 = new Worker('Nils', 'Bor', 'scientist'),
- worker1 = new Worker('Albert', 'Einstein','scientist'),
- worker2 = new Worker('Anatoly'),
- worker3 = new Worker('Vladimir', 'Zelensky', 'comedian')
- describe('Wokers tests', () => {
- it('Creation tests', () => {
- assert.strictEqual( worker0.name, 'Nils' )
- assert.strictEqual( worker0.surname, 'Bor' )
- assert.strictEqual( worker0.profession, 'scientist')
- assert.strictEqual( worker1.name, 'Albert' )
- assert.strictEqual( worker1.surname, 'Einstein' )
- assert.strictEqual( worker1.profession, 'scientist')
- })
- it('Methods tests', () => {
- worker0.doWork()
- assert.deepEqual(worker0.stats,{totalDays:1,hoursPerWeek:8})
- worker1.doWork().doWork(7).doWork(9).doWork(11).doWork(5)
- assert.deepEqual(worker1.stats,{totalDays:5,hoursPerWeek:40})
- worker2.doWork().doWork().doWork().doWork().doWork().doWork().doWork().doWork().doWork()
- assert.deepEqual(worker2.stats,{totalDays:9,hoursPerWeek:24})
- worker3.changeProfession('president')
- assert.strictEqual(worker3.profession, 'president')
- })
- it('Error test', () => {
- let throwed = false, message, error
- try {
- worker0.changeProfession()
- } catch (err) {
- [error, message] = [err, err.message]
- }
- expect( error ).to.be.an.instanceof(Error, 'Throwed error should be instance of "Error" constructor!')
- assert.strictEqual( message, 'The profession was not transferred!' )
- })
- it('TypeError test', () => {
- let throwed = false, message, error
- try {
- worker1.changeProfession(1234)
- } catch (err) {
- [error, message] = [err, err.message]
- }
- expect( error ).to.be.an.instanceof(TypeError, 'Throwed error should be instance of "TypeError" constructor!')
- assert.strictEqual( message, 'Incorrect new profession type!' )
- })
- })