Posts

Showing posts from November, 2016

C++ Beginner: Lesson 2 - Introduction to Qt environment

Image
The series of lessons in C++ will be developed based on tasks differently from the java lessons which are based on specific concepts for each lesson and will be depended on Qt Creator IDE, which is a very powerful IDE, strength of which we will see in every lesson and project. In this lesson we will explore a little bit more the environment of Qt Creator. As we saw in the lesson 1 , after we create the project we get the window with the view shown in the figure 1. Figure 1: Design mode The square marked with number 1 in the figure 1 shows the are of the window which we can edit by adding other elements or by changing its properties. The square marked with number 2 shows the toolbox area from where elements can be dragged and dropped in the are 1. The square marked with number 3 shows the properties of the selected item, in case of the figure 1 the selected item is the entire window, but we can select other elements that we drop on window in order to see their properties or ch

Java Intermediate: Lesson 2 - GUI

Image
Being that in the lesson 1, intermediate level we saw the concept of class it is easier to understand the structure of an application with Graphical User Interface. In the case of this lesson is used NetBeans IDE and the application in this case is platform depended during the phase of development because it uses the libraries of the NetBeans IDE. If it could be considered that it was not mandatory to use NetBeans IDE until now, in this lesson this fact changes because of the reason I mentioned above. In order to create a GUI project in NetBeans IDE it is necessary to follow the same steps with the ones followed during the creation of a normal project, so File -> New Project ... -> Java -> Java Application and click finish after determining the name of the project. After the creation of the project, the next step that follows is the creation of a JFrame Form. In order to create a JFrame form on NetBeans IDE it is necessary to right-click on the name of the project on Proj

Exercise Beginner: Rotate matrix 90 degrees

Image
Request: Write a program that rotates the given matrix 90 degrees clockwise. The matrix size is n × m. (1 ≤ n, m ≤ 50, -10^9 <= matrix elements <= 10^9). Print the rotated matrix in the same format like input. Solution We will solve this problem with a concrete case, by using the matrix shown bellow: Example code: 1, 6, 4, 7, 9, 3, 3, 5, 8, 3, 5, 6, and the result for this specific case should be as follow: Example code: 3, 1, 5, 6, 8, 4, 3, 7, 5, 9, 6, 3, In order to reach such result we need the result matrix hight to be same as the input matrix width and the result matrix width to be same with the input matrix height. The new location In order to have a matrix in code we have to declare a two dimensional array as seen bellow. Example code: int matrixToRotate[][] = {{1,6,4,7,9,3}, {3,5,8,3,5,6}}; In order to implement the logic described bellow we will have to write the following code. Example code: public

Java Intermediate: Lesson 1 - class

Image
Classes are a very important structure in object oriented programming. They can be considered like templates or set of rules which determine what an instance can do and how it can be. Instance is an object which is created through the new keyword. For example: Example code: Car ferrari = new Car(); Where ferrari is the instance of Car and Car is a class as shown in the example code bellow. Example code: public class Car { private String color; private float speed; public void setColor(String color){ this.color = color; } public String getColor(){ return color; } public void setSpeed(float speed){ this.speed = speed; } public float getSpeed(){ return speed; } public void accelerate(float speedToAccelerate){ speed = speed + speedToAccelerate; } } Speed and color are the attributes of the car which store the state of instances. We will cover static attribu