battle programmers alliance
Would you like to react to this message? Create an account in a few clicks or log in to continue.

battle programmers allianceLog in

battle programming a forum for elite programmers with extreme will power to sharpen their skills

descriptionupgraded Brain class is the best MVC software design pattern Emptyupgraded Brain class is the best MVC software design pattern



class Brain(private val MVC: actionable, private val chi: thinkable) {
    fun doIt(ear: String, skin: String, eye: String) {
        val result = chi.think(ear!!, skin!!, eye!!)

the class is constructed with an actionable and a ChobitV2 (thinkable)

example actionable :



import com.yotamarker.lgkotlinfull.LGCore.actionable;

import org.jetbrains.annotations.NotNull;

public class CerabellumV3 implements actionable {
    private MainActivity main;
    public CerabellumV3(MainActivity main) {
        this.main = main;

    public void act(@NotNull String thought) {

the chobit is the AI it processes the input and produces an output result.

the actionable (which is the MVC model) has access to the main classes hardware actions
such as SMS sending, robotics and so on.

depending on the chobit result you may want to engage on such hardware actions.

the actionable act function can be implemented to, for example, activate a public function to send an SMS
if the result is "some specific string".

on this example implementation the actionable simply uses some toast function I wrote on the main activity
to display the result as a toast message.

see MainActivity


package com.yotamarker.lgkotlinfull

import android.os.Bundle
import android.view.View
import android.widget.Toast
import com.yotamarker.lgkotlinfull.LGCore.Brain
import com.yotamarker.lgkotlinfull.LGCore.ChobitV2
import com.yotamarker.lgkotlinfull.skills.Personality2

class MainActivity : AppCompatActivity() {
    var chii: ChobitV2? = null
    var brain: Brain?=null
    override fun onCreate(savedInstanceState: Bundle?) {
        chii= ChobitV2(Personality2())
        brain= Brain(CerabellumV3(this),chii!!)
    fun engage(view: View){
        Toast.makeText(this, editText.text.toString(), Toast.LENGTH_SHORT).show()
    public fun toaster(str:String){Toast.makeText(this, str, Toast.LENGTH_SHORT).show()}

this keeps the code much cleaner and the algorithmic logic can be used for other projects or even other programming languages

MB over and out emp it up

descriptionupgraded Brain class is the best MVC software design pattern EmptyRe: upgraded Brain class is the best MVC software design pattern

to keep code organizedmaxed any additional hardware related classes or files should be kept in a package (directory) called hardware

MB over and out emp it up
privacy_tip Permissions in this forum:
You cannot reply to topics in this forum