My First Contribution in GitHub

Following my last blog Goals for Hacktoberfest, I will be contributing my first pull request. Looking for the right issue was more difficult then I thought it was going to be. I spent hours looking for an issues that I would be able to complete, projects that I have an interest in, etc. Finally I found a issue I thought was interesting, and was able to contribute.


Project:

The project I am contributing today is called MazeProject. The project is a simple maze generation program. The maze is created with hexagons. I found this project interesting because I have created similar programs like this on my own time. This project was developed in Java. I have a lot of experience with Java, so this is a great way for me to easy my way into the open source community and refine my skills.


Issue:

The issue posted from the owner was an enhancement to add customizable size configuration in the programs UI instead of changing it manually in code. This is not a difficult issue, so I decide to work on this issue for my first pull request in Hacktoberfest. I left a comment saying to assign the issue to me, and then I started working on the issue.


Git commands I used after forking the project:

git clone https://github.com/ImmutableBox/MazeProject.git
cd MazeProject/
git checkout -b issue3

Solving the Issue:

The method I used to solve this problem would be to add a prompt dialog box that would accept two inputs from the user “Board Width” and “Board Height”.

To create this prompt I will be using JOptionPane and JTextField. JOptionPane has a function called showConfirmDialog which creates a confirm dialog box-OK or cancel dialog box- for the user to input values. showConfirmDialog takes in four parameters, first parameter being the parent component and because there is none I leave the first parameter as null. Second parameter takes an object. Since I want text to prompt the user on what to input and the input field itself, I create an array of objects (I create an array since there are more than one option):

Object[] message = {
             "Board Width:", boardWidth,
             "Board Height:", boardHeight
         };

As you can see an object contains two values, a string("Board Width") and JTextField(boardWidth). The string is the message we prompt the user, and JTextField is the actual input field. The third parameter showConfirmDialog takes is the title as you can see in the picture above I set the title to “Setting maze size”. The last parameter is the format of the dialog box. I set the fourth parameter to JOptionPane.OK_CANCEL_OPTION which is a macro found in the JOptionPane class (Dialog box is styled with OK or CANCEL buttons). Once we have the value from the user we enter the numbers into the maze generate function MazeGenerator.generate and generate the maze.


Git commands used:

git add src/Main.java
git commit -m "Fix #3: Adding maze size configuration"

Pull Request:

I created my pull request and sent it to be reviewed. I am currently still waiting for the pull request to be merge into the master branch. For my next pull request I plan to work on a project that has a bigger community, since this project only had one contributor.


Links:

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s