Monday, 13 June 2016

Passed Java OCA Programmer 1 1Z0-808!!!

Passed, it took a significant amount of work and hopefully I now have the confidence to build more of my own things. To avoid that I did a programming challenge. 

What did help on the exam is the enthuware tests, lots of unique questions with the tougher items having in depth descriptions. I liked the Jeanne Boyarsky and Scott Selikoff study guides, they do keep track of errata

Grey, white and red cover with the image of a light house for exam 1Z0-809

Having made a start, I am now thinking 3 months is optimistic if I am to include practice exams, jpassion, and other exam preparation. It is exciting as there are more interesting language features in the OCP exam, steams, lambdas, generics, and concurrency. They are a lot more fun than how many ways can the examiner confuse me with implicit type casting and chaining string methods.

I also need to keep my eye on the main goal of getting a job as a developer rather than just passing an exam, I have some ideas for my own projects.

There is a lot of doubt, as it is easy to give up where being a developer relies on patience, persistence, and methodical thought which if I am can get that down it would improve much more than my development career.

Pacman walk-through!

Challenge to transpose text, 

Dark coloured IDE showing solution and result of transpose




What I did notice from the solutions on reddit is that they are all different to each other including mine, although I do not agree with the solution using exceptions as program flow.

package com.company;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner keyboard = new Scanner(System.in);
        String line, EOF = "-1";
        List<String> lines = new ArrayList<>();
        boolean hasNextLine;

        do {
            line = keyboard.nextLine();
            hasNextLine = !line.equals(EOF);
            if (hasNextLine) {
                lines.add(line);
            }
        } while (hasNextLine);

        int rows = 0;
        for (String aline : lines) { 

            if (rows < aline.length()) rows = aline.length(); 
        }
        int cols = lines.size();

        char[][] charGrid = new char[rows][cols];
        for (char[] row : charGrid) {
            for( int i = 0; i < row.length; i++) { row[i] = ' '; }
        }

        for ( int i = 0; i < lines.size(); i++) {
            for (int j = 0; j < lines.get(i).length(); j++) {
                charGrid[j][i] = lines.get(i).charAt(j);
            }
        }

        for (char[] lineOfChars : charGrid) {
            System.out.println(new String(
lineOfChars));
        }
    }
}

No comments:

Post a Comment