The future has comeThe attributes of 20th century were a hoover, a washing-machine, a TV-set and a car. If you continue to wash clothes by hand, ride a horse, use candles for illumination, then, by standards of 20th century, you are living in 19th. The internet, cell phone, Skype, social networks, became the attributes of 21th century. By means of the Internet it is possible to get access to any information well-known to humanity. It is possible to work and do business, get education and teach in the web. By means of social networks it is possible to find a friend, a job, a girlfriend, a group by interests. You can become acquainted practically with any person in the world, to ask advice or help from that person. You can befriend people in the whole world, and then come to visit or invite them to you place, or go somewhere together. By means of Skype you can communicate with the friends, brothers, sisters, parents, relatives, and any other people in the whole world. Free visual communication in any place of the world. People didn’t even dare to dream about it 20 years ago. Now it is an ordinary fact. GoogleStreetView enables you to “walk” the streets of any city of any country on earth. You can choose a place, where would like to live, and move there. The owner of a "modern telephone" can: talk, write messages, send pictures, surf for information in the web, install hundreds of millions of free applications. What else? Make videos-calls, listen to some music, watch video, make video, take photos, see the location on a map, put location-marks on it, use the organizer, communicate in social networks and “like” kittens. You can learn English in a year (or any other language), listening to audio courses, when you go to work and from work. Any information is accessible in the web, any textbooks. Do you want the video-lecture of the best world universities with sub-titles? There they are as well. If you speak English, you can write a book, publish it on Amazon and earn a fortune. You can order a web-site for several hundred dollars and do business over the web all over the world. Stop living in 20th century waiting to be told what to learn, how to learn, what to do and where to live. Decide it on your own. Opportunities to change your life surround you on every step. And the last thing, there is this joke: A flood happened. Everyone is running for their lives, except for an old and very devotional Jew, who sits and prays. A truck is passing by, and people in it shout to the Jew: - Haim, get in, save yourself! - I’ve been praying all of my life and kept to all the traditions, God will save me, - Haim answers. Water is getting higher, up to the windows. A boat floats by. Same question, same answer. Water keeps getting higher, up to the roof. Haim sits and prays. A helicopter flies by. Same question, same answer. And Haim drowned. And in the Other World he began chiding God: - I’ve been praying all of my life and kept to all the traditions, why did You not save me? - I’ve sent you a car, a boat and a helicopter, so why are you complaining?
You have reached a new level
Level 1- Congratulations on your first level! - Thanks! It was easier than I thought! - And I had a lot of fun! - You’ll find it even more exciting. Now, I’ll prove it. Are you ready? - Let’s roll!
1 Risha, acquaintance with the program.
1 Risha- Hi, my young friend. I hope you haven’t forgotten that I’m bureaucrat in 16th generation. I would never become so successful if I didn’t systematize all my knowledge. I have a lot of useful tips that will help you with some tasks. First, let me tell you what an ordinary Java program is. - Ok, go ahead. - Fact one. A Java program consists of classes. Each class is stored in a separate file. A file name matches a class name; the file extension is .java. - The program comprises of a .java file set, in each file there is a code of one class, right? - Absolutely right, Amigo! If the file name is MyCat.java, it contains MyCat class. - Fact two. If we have a lot of files with classes, we group them into folders and subfolders. Note that classes are grouped into packages and subpackages. Names of packages and subpackages have to be specified in a class code. They must match names of folders and subfolders on the disc. - So we have files arranged into folders on the one side and classes arranged into packages on the other. The class name must match the name of the file in which the class is described. A package name matches the name of the folder to store the class. - Tell me more about this. - Names of subpackages are described separated by a point, almost like links on the Web. - So if you have a Cat class located in “animals.pets” package, it means that A) There is src folder on the disc. All project files are stored in this folder; B) Inside it there’s a folder animals which comprises of a folder named pets, C) In the pets folder there’s a file Cat.java, which contains a class code Cat. - I kinda understand, but I’m not sure. - Well then, the structure of classes and packages is the same as the structure of the folders and files on the disk. If there’s a file House.java located in the folder src/com/houses/ then it means that there’s a class House, which is in the package com.houses. - In this context, the full file name is «com/houses/House.java», and the full name of the class com.houses.House. - Got it. - Good, you are so brainy. Now watch the screen - here’s a small class code. I’ve marked all the key points: - Everything’s clear as much as it can be on the first try. Heh, heh. - Bully for you! You needn’t understand much. The trick is to catch something now, you’ll understand everything else later. Well, then, I’m done for today, let someone else take care of you.
2 John Squirrels, How to use this online course- Good day, Amigo. I am John Squirrels, the Captain of Galactic Rush spaceship. - Good day, Captain. - Today I am going to explain you how our learning process is arranged.
CodeGym GuideI always told my students that computer programming is easy and interesting. Now you can make sure of it by yourself. The goal of the course is to enjoy studying, have fun and gain real programming skills in Java, which will help you to get a job as a software developer. That’s why there are many practical tasks in the course. Task complexity grows gradually from simple to the most complex ones.
How the course is arrangedThe course consists of 40 levels. Each level contains 10-12 lectures and 20-30 practical tasks. Each level corresponds to a separate solar system on the star map below, and lectures in the level are planets of the solar system. Each opened lecture is a flight to another planet. When all lectures are opened, the spaceship flies to the next star system. For solving practical tasks, watching videos and many other things you get a reward – a few units of “dark matter”. To move to the next lecture or level, you need to do "a flight on the spaceship," which requires "one refueling ship": 5 units of dark matter are needed to refuel the spaceship.
Moving to the next levelTo move to the next level, you need to go through all lectures in the current level. To move to the next lecture, you need to press the big Green Button: When you move to the next lesson, your spaceship flies to another planet. If you run out of fuel or your ship isn’t filled, the button will not be able to press and will look like this: You can fill the ship in the section "My Page". If you cannot refuel the ship because there is no dark matter, you need to solve several tasks and earn it. To solve a task use the Yellow Button, that is to the left of lectures, near practical tasks:
Practical TasksEntering the code as in a sample - this is the most simple practical task. To solve this task, you must enter Java code at the lower part of the window. The code should be identical to the sample (it is at the upper part of the window). Write a program - a practical task of average complexity. To solve it, you should write the program in Java. You need to find out how to solve the task, and enter the code solution in the main window. Then press the button: To make your studying easier, as well as for simplifying the checking process of the program, the code should be written only in the place marked by the comment "Add your code here". In the case of a successful compilation, the program will automatically be checked - whether current task is solved correctly. If the program displays something on the screen, there is a special window below – the Output window. It shows everything that the program has displayed to the screen at last run. You can always hide the window with the code to see something in lectures or to postpone the solution of the task. Simply press the button on the top right corner. When you come back to this task again, your previous code stays there. The button looks like this: If the size of the window with code is too small, you can maximize it by clicking the maximize button (available from the 4th level): Home tasks must be solved in Intellij IDEA (available from 3rd level). This is a special program for developers (IDE) to make coding easier. I wrote a plugin for IDEA, which will give you the ability to check whether your program is correct in less than a second. The plugin consists of only two buttons: Left button shows the list of available tasks for you: Right button sends the task to the server for checking: You can also earn "dark matter" watching videos:
3 Risha, Basics of memory work- It’s me again: I just forgot to explain you something. I want to tell you about variables and memory addressing. Don’t take much thought about it, but if you remember something - that’s a mercy! - Love your approach. Good, if point taken, if not - well, okay. - If it goes, it goes, don’t force it. That’s obvious. Why, is it different with you? - It is. We have another approach to studying: if you don’t want to, you do have to. - Hmm, what an outdated approach. Just fancy, you waste lots of time and effort, and there’s almost no result. - Dead right! But let that pass. - All right. Imagine Excel. Everybody knows Excel. An Excel sheet consists of cells, each cell has its unique number (A1, A2,…B1, B2). You can put some value in a cell or obtain stored value, when you know cell number. A computer’s memory is arranged in much the same way. - So far, it’s clear. - At runtime the program and its data are stored in memory. The entire computer’s memory is represented by small cells - bytes. Each cell has its unique number - 0,1,2,3, ... (starting with zero). If you know the cell’s number, we can save there some data or take the data from the cell. Some cells store the program code, a processor’s command set, the other store the program data. The number of each cell is also called its address. - Processor, commands… - Professor has told me something about it, but just a little. - Processor is a thing that can run commands from a program brought into memory. Almost every processor command looks like that: "take data from some cells, make something with them, and then put the result into other cells". Combining hundreds of them, we thus get complex and useful commands. - Why on earth do I need all this? - When a variable is declared in a code, it is given a piece of unused memory, usually a few bytes. When declaring a variable you also need to specify the type of information that the program will store in a variable: numbers, text, or other data. For convenience, each variable is given a unique name. - So then, a variable is a name and a type, or a piece of memory and a value? - All combined. Let’s have a look at a few examples.
4 Elly, Acquaintance with the types of int and String- Hey, Amigo. - Hello, Eleanora Carry. - Call me just Elly, so it will sound not that officially. - OK, Elly. - I think with my assistance you’ll quickly become one of the best programmers. I have great experience in teaching beginners. Follow me, and it will go like clockwork. Let’s get started. - In Java there are two basic types: String and int. In String we store strings/text, and in int numbers (integers). To declare a new variable, you need to write its type and name. The name must not match any other name of variable and/or function. - When declaring variables you can immediately enter values to them. - To enter a new value to a variable you need to use equals sign “=”. It’s also called an assignment operator. Assignment is putting to a variable a value taken from another variable or calculated based on several variables. - A new value of a variable can be calculated based on expression to the right of sign «=». The expression can contain the same variable. - You can combine strings using the plus sign: - Sometimes it’s convenient to use a string consisting of one or more spaces: Now I explain you how to display text and value of variable: - By the way, Diego asked me to give you a couple of tasks. Don’t be surprised, they are in the style of Diego:
|Write a program that displays «If something goes wrong at the office, blame the guy who can't speak English.»
|Write a program that displays «I don't get excited by money, they soothe me.» 10 times.
|Write a program that displays «If you don't like the way I drive, stay off the sidewalk.».
5 Diego, Good advice- Hey, buddy! It’s me again, do you remember? The one who will teach you right staff! - No one understands you better than me, because we are both robots. So don’t listen to the theory of those "bags of bones". I am the one you should listen to. And I say: nothing can replace practice. You’re not going to learn to swim reading a swim guide, are you? Ha-ha. Who practices wins. That’s what robots do. - Here’s a new task: write a program to display «Kiss my shiny metal ass!»
A new text output task
Write a program that displays «Kiss my shiny metal ass!»
6 Risha, Signing of the contract- It’s me again! I think you already know enough to start making smart decisions. It’s high time to sign a contract with your new employer. You have to fill in an application, here’s a model form. Just display its text on the screen, that’s all. Sign it blind, I always do so.
|Task: display text
My name is Amigo.
My salary for the first year will be $100
Thanks for being generous, my friend Risha!
|New task: CONTRACT. Write a program to display:
My name is Amigo.
My salary for the first year will be $60,000
Kiss my shiny metal ass!
7 Elly, Output to screen- It’s me again. Today you have three lessons. This is the second one! Sit back and listen, I’ll tell you about the output to the screen. It’s simple and easy: - Could you once again tell me about print() and println()? - The print() function displays entire text letter by letter. When the line is full, text appears on the next line. You can interrupt output on the current line, and make the text display on the next line if you use the println() function. - Got it. And what’s that magic of adding strings to numbers? - If a number is added to a number, the result will be a number: 2+2 equals 4. If a string is added to a number, then the number is converted to a string and then two strings are combined. - Yeah. I kinda thought so seeing the examples, but you never know. Thanks for the interesting lecture, Elly.
8 Bilaabo, Comparison with Pascal- Hi! I am Dr. Laga Bilaabo, I’m an alien, hope we’ll be friends. - Me too. - On our home planet, we use the progressive programming language Pascal, instead of outdated Java. Here’s a little comparison between Java and Pascal: - It’s the same program written with various languages. As you can see, in Pascal it takes less lines; it’s a sign of Pascal’s progressiveness. - I think this comparison can improve your understanding of Java, if you have ever seen Pascal. - No, I haven’t. But it would still be interesting to look at comparison of two different programming languages. - Yeah, you are right. Let’s continue. - In Pascal, we put the written code in the program body, procedures or functions. In Java, it’s all been greatly simplified: the program body, procedures and functions were replaced by functions, and functions called methods. - In the Pascal column, I see «program body», «function» and «procedure», and in Java column there are only functions. It looks a bit strange. - Yes, it seems very strange to everyone in my planet, but people like to simplify everything. - In Java, all code is in functions, so, to declare a function, you don’t even need to write function, as you do in Pascal. - It’s that simple: If the line of code is of «Type + name» form, it’s a declaration of either a function or a variable. If brackets follow the name, then it’s a declaration of a new function. If there are no brackets, then a new variable is declared. - Declaration of variables and functions in Java is very similar, let’s compare: A function has the name getName and the return type String. - More than this, Java functions can’t exist by themselves. They have to be inside of a certain class. Therefore, when humans need to write a small program in Java, they must first create a class, then write the function main inside it, and then write their code in it. Earthlings are such freaks. - So, as you see, Pascal is much better. And if I could choose I would teach you Pascal. But my crew forced me to give you some tasks on Java. At least I’ll try to give you some good motivation:
|Write a program that displays 9 times: «Life is not fair - get used to it.».
|Write a program that displays 4 times: «The most important stakeholder in your life is You.».
|Write a program that displays 16 times: «What you plant now, you will harvest later.».