fukuoka

Printing every possible combinations of ABC (Swift 2.2 )

Posted on Updated on

I had time this evening .. so I figured why not dig up some example code I copied from a tutorial online and modify it to show every possible combinations of the letters A, B and C.

Only this time instead of showing through a terminal I would print it on an iPhone app. So here it is ..

スクリーンショット 2016-03-28 21.19.43

Source code:

import UIKit

class ViewController: UIViewController
{
    @IBOutlet weak  var totalPermutations: UILabel!         // print total permutations count of ABC
    @IBOutlet weak  var _comboTextView: UITextView!         // print every combination of ABC
    @IBOutlet       var _outputLabel: UILabel!
                    var _currentCount = 0

    let combinationsArray: [String] = ["A", "B", "C"]

    /**
     * Initialization
     */
    override func viewDidLoad()
    {
        super.viewDidLoad()
        printCombinations()
    }

    /**
     * Print every combination of ABC
     */
    func printCombinations()
    {
        var totalCombinations = 0
        var str: String = ""
        for letter in combinationsArray {
            for nextLetter in combinationsArray {
                for nextNextLetter in combinationsArray {
                    totalCombinations++
                    str += (letter + nextLetter + nextNextLetter + "\n")
                }
            }
        }
        totalPermutations.text = ("Permutations: " + String(totalCombinations))
        _comboTextView.text = str
    }

    /**
     * Memory warning
     */
    override func didReceiveMemoryWarning()
    {
        super.didReceiveMemoryWarning()
    }

    /**
     * Start counting
     */
    @IBAction func addOneButton(sender: UIButton)
    {
        _currentCount++
        _outputLabel.text = "クリック回数は:\(_currentCount)"
        _outputLabel.textColor = UIColor.redColor()
    }
}

Edit: Added total permutations counter
Github: https://github.com/benji011/counterApp

‘ReceiveActorBeginOverlap’ marked ‘override’ but does not override any member functions – (Unreal Engine 4 with C++, Mac OSX)

Posted on Updated on

スクリーンショット 2015-09-20 21.15.00

After playing with Cocos2dx and Unity 5, I decided to challenge myself even further by working on a test project (FPS, 3rd person shooter etc) using Unreal Engine 4 with C++.

While working on a first person shooter project, I was in the middle of creating power up / health pick up items. All was going well until I ran into this error message:

‘ReceiveActorBeginOverlap’ marked ‘override’ but does not override any member functions

My source code below:

.h header file

    #pragma once
     #include "GameFramework/Actor.h"
     #include "HealthPack.generated.h"

    UCLASS()
    class TESTFPS_API AHealthPack : public AActor
    {
	    GENERATED_BODY()
	
    public:	
    	AHealthPack();	
	    AHealthPack(const FObjectInitializer& ObjectInitializer);	

	    virtual void 	BeginPlay()  override;
	    virtual void 	Tick( float DeltaSeconds ) override;
	    virtual void 	ReceiveActorBeginOverlap(class AActor* Other)	override;	

And in my .cpp implementation file l declare this method like this:

    void AHealthPack::ReceiveActorBeginOverlap(class AActor* Other)	
    {
     	if (Other != NULL)
	    {
	    	if (CanBePickedUp(Cast<ATestFPSCharacter>(Other)))
	    	{
	    		HandlePickUp(Cast<ATestFPSCharacter>(Other));
	    		HandleEffects();
	    		removeFromWorld();
	    	}
	    }
    }

Turns out that “ReceiveActorBeginOverlap” is not virtual so you cannot override this method (anymore). So to solve this you need to override <strong"NotifyActorBeginOverlap" and then call Super inside this function. Modifying the lines above to below resolves my error:

.h header file:

virtual void 	NotifyActorBeginOverlap(class AActor* Other)	override;

.cpp implementation file:

/**
 *	Check if we can pick up a health pack
 */
void AHealthPack::NotifyActorBeginOverlap(class AActor* Other)	
{
	Super::NotifyActorBeginOverlap(Other);

	if (Other != NULL)
	{
		if (CanBePickedUp(Cast< ATestFPSCharacter >(Other)))
		{
			HandlePickUp(Cast< ATestFPSCharacter >(Other));
			HandleEffects();
			removeFromWorld();
		}
	}
}

BBQ & Japan updates

Video Posted on Updated on

It’s been another month since I last updated and as expected a lot of things have happened.

I used to work at a chinese restaurant the school got me. And while I am grateful for their efforts I didnt like it very much. It was good to work with Japanese chefs but there was absolutely no time to talk freely since it was always busy. But other than that I was just washing dishes and maybe cooking a little but not much. Carrying hot plates straight out of the machine did some damage to my hands so part of my skin in my fingers kinda melted off a bit and now i have to moisturize it like crazy.

Good news is though I quit that job over a week ago and I now work for Seven Eleven, which is a 24 hours convenience store all over Japan … kinda as popular as Starbucks now that I think about it. Seriously, theyre everywhere. I found the job and applied by myself and got it within that week. So now I have more chances to work with Japanese people and talk to them freely and theyre all extremely nice people too!

School was on a 1 1/2 month Summer break and 2-3 weeks later we’re now in Autumn break for a week. It’s … well I haven’t got any complaints because I still study but its nice to have someone help me in a while.

 

1267766_448923848555585_2031425408_o

A few days ago me and some friends went to a BBQ with the owner of the Japanese bar Rough Times. They don’t have a website but they are mentioned here in a food blog site:

http://tabelog.com/fukuoka/A4008/A400802/40025518/

Just to better explain what sort of life I have in Japan I made a video and decided to upload it here! So without rambling on, please check it out in HD

Laters!

《The Last Samurai 翻訳》 + small update

Posted on Updated on

Hi, Sorry I haven’t updated in a very long time. But to make it brief on the last one:

1) I’m finally leaving my part time job in that chinese restaurant because I got hired at an even better place to work, closer, better environment and better experience. Pay wise, not so much different. Still, good.

 

2) Studying has been on and off, but made up a lot in a lot of non english leisure time (films, books & friends etc)

3) It’s been pretty hot. Sweating like crazy.

 

Anyway I few weeks ago or two I watched The Last Samurai and one part of the movie got me thinking on how to translate it in my own words. So I finally got to it and here it is:

 

“From the moment they wake they devote themselves to the perfection of whatever they pursue. I have never seen such discipline. I am surprised to learn that the word ‘Samurai’ means‘to serve’…” 

「起きる瞬間から目的まで一部たりともミスのないように、彼らはそれなりに前進する。私はこれ程の自制心そのものを見たことがない。侍というのは誰かのためにこうするわけだとはね」

 

また更新するからお楽しみ

Ben

Off to Japan!

Posted on Updated on

画像

Almost set for Japan now. Decided to make this blog all english since I already have a Japanese one. And besides, I already told my family & most of my friends so I’ll use this more to update everyone back home, rather than writing separate E-mails back & forth. I think this should be better.

 

Some of my family and friends already know this but to those who don’t, Today’s the day I’m finally going to Japan to study for a year. Have been wanting to do this for a long while since uni but I couldn’t because of my degree (which was software engineering BSc)  and that got in the way with my minor degree. At that time (2009) it was impossible to do a year out in Japan. Although I think now Oxford Brookes University made it possible. I’m not sure, just a word of mouth so someone can correct me.

 

The school I’ll be going to is called NILS. If you’re interested in going too, then here’s the website: http://www.ulearnjapanese.com 

Ok I have to make this entry quick cause I still have left over stuff to pack then check, and then a friend is coming over to drop some stuff off and then I gotta skype some friends. Rush rush rush ……. Why in the world did I think it was a good idea to start packing 2 days before I would leave the country?!