diff --git a/data/part-11/2-packages.md b/data/part-11/2-packages.md index 6ba5eceaa..6ef70fce5 100644 --- a/data/part-11/2-packages.md +++ b/data/part-11/2-packages.md @@ -22,7 +22,7 @@ hidden: false -As the number of classes implemented for the program grows, remembering all the functionality and methods becomes more difficult. What helps remembering is naming the classes in a sensible manner and planning them so that each class has one clear responsibility. In addition to these measures, it's wise to divide the classes into packages. Classes in one package might share funcionality, purpose, or share some other logical property. +As the number of classes implemented for the program grows, remembering all the functionality and methods becomes more difficult. What helps is naming the classes in a sensible manner and planning them so that each class has one clear responsibility. In addition to these measures, it's wise to divide the classes into packages. Classes in one package might share funcionality, purpose, or some other logical property. @@ -30,7 +30,7 @@ Packages are practically directories in which the source code files are organise -IDEs offer existing tools for packet management. Up until this point we have only created classes and interfaces into the default package of the Source Packages part of the project. You can create a new package in NetBeans by clicking the right mouse button in the Source Packages section (which relates to the packets of the project), and then choosing *New -> Java Package...*. +IDEs offer existing tools for package management. Up until this point, we have only created classes and interfaces in the default package of the Source Packages folder of the project. You can create a new package in NetBeans by right-clicking on the Source Packages section (which contains the project's packages), and then selecting *New -> Java Package...*. @@ -38,7 +38,7 @@ You can create classes inside a package in the same way you can in the default p -The package of a class -- i.e., the package in which the class is stored -- is marked at the beginning of the source code file with the statement `package *name-of-package*;`. Below, the class Program is in the package `library`. +The package of a class (the package in which the class is stored) is noted at the beginning of the source code file with the statement `package *name-of-package*;`. Below, the class Program is in the package `library`. -Every package -- including the default package -- may contain many packages. For instance, in the package definition `package library.domain` the package `domain` is inside the package `library`. The word `domain` is often used to refer to the storage space of the classes that represent the concepts of the problem domain. For example the class `Book` could well be inside the package `library.domain` since it represents a concept in the library application. +Every package, including the default package, may contain other packages. For instance, in the package definition `package library.domain` the package `domain` is inside the package `library`. The word `domain` is often used to refer to the storage space of the classes that represent the concepts of the problem domain. For example, the class `Book` could be inside the package `library.domain`, since it represents a concept in the library application. -A class can access classes inside a package by using the `import` statement. The class `Book` in the package `library.domain` is made available for use with the statement `import library.domain.Book;`. The import statement that are used to import classes are placed in the source code file after the package definition. +A class can access classes inside a package by using the `import` statement. The class `Book` in the package `library.domain` is made available for use with the statement `import library.domain.Book;`. The import statements that are used to import classes are placed in the source code file after the package definition. -There is a package called `mooc` included in the exercise base. We will create the functionality of the program inside this package. Add the package `ui` inside the package `mooc` (after which the package `mocc.ui` should be available), and add an interface called `UserInterface` in it. +There is a package called `mooc` included in the exercise. We will create the functionality of the program inside this package. Add the package `ui` inside the package `mooc` (after which the package `mooc.ui` should be available), and add an interface called `UserInterface` in it. -The interface `UserInterface` is to define the method `void update()`. +The interface `UserInterface` defines the method `void update()`. @@ -169,7 +169,7 @@ The interface `UserInterface` is to define the method `void update()`. -In the same package, create the class `TextInterface` that implements the `UserInterface` interface. Implement the method `public void update()`, required by the interface `UserInterface`, so that the only thing it does is to print the string `"Updating UI"` by calling the method `System.out.println`. +In the same package, create the class `TextInterface` that implements the `UserInterface` interface. Implement the method `public void update()`, required by the interface `UserInterface`, so that the only thing it does is print the string `"Updating UI"` by calling the method `System.out.println`. @@ -267,15 +267,15 @@ Within the exercise base, create three packages: `a`, `b`, and `c`. Create class -

Every project you see in NetBeans are in your computer's file system or on some centralized server.

+

Every project you see in NetBeans is in your computer's file system or on a centralized server.

-In the project directory `src/main/java` there are the source code files of the program. If the package of a class is library, that class is stored inside the `src/main/java/libary` folder of the source code directory. You can also check the concrete project structure in NetBeans in the **Files** tab, which is normally next to the **Project** tab. If you cannot see the **Files** tab, you can make it appear by choosing the option **Files** from the dropdown menu **Window**. +The project directory `src/main/java` contains the source code files of the program. If the package of a class is library, that class is stored inside the `src/main/java/libary` folder of the source code directory. You can also check the concrete project structure in NetBeans in the **Files** tab, which is normally next to the **Project** tab. If you cannot see the **Files** tab, you can make it appear by choosing the option **Files** from the dropdown menu **Window**. -Application development is normally done in the **Projects** tab, where NetBeans does not show the files that the programmer need not concern themselves with. +Application development is normally done in the **Projects** tab, where NetBeans hides unimportant files from the programmer. @@ -283,7 +283,7 @@ Application development is normally done in the **Projects** tab, where NetBeans -Until now we've used two access modifiers. The modifier `private` is used to define variables (and methods) that are only visible inside the class where they are defined. They cannot be used from outside that class. The methods and variables defined with `public`, on the other hand, are available for everyone to use. +Until now, we've used two access modifiers. The modifier `private` is used to define variables (and methods) that are only visible inside the class where they are defined. They cannot be used from outside that class. The methods and variables defined with `public`, on the other hand, are available for everyone to use. -If you create an object of the `UserInterface` class above, its constructor and `start` method are callable from anywhere in the program. The metho `printTitle` and the variable `scanner` are available only from within the class. +If you create an object of the `UserInterface` class above, its constructor and `start` method are callable from anywhere in the program. The method `printTitle` and the variable `scanner` are available only from within the class. @@ -428,7 +428,7 @@ public class Main { -If a class is in a different package, the method `printTitle` cannot be called. In the example below the class `Main` is in the package `library`. Since the `printTitle` method is in the package `library.ui` and it has the package access modifier, it cannot be used. +If a class is in a different package, the method `printTitle` cannot be called. In the example below, the class `Main` is in the package `library`. As the `printTitle` method is in the package `library.ui` and has the package access modifier, it cannot be used. -The next subchapters list one possible division for the operation of the program (excluding the main progrma class). +In the next subchapter, we list one possible organization for the operation of the program (excluding the main program class). @@ -685,7 +685,7 @@ The next subchapters list one possible division for the operation of the program -The classes that represent concepts of the problem domain are ofter placed inside a package called `domain`. Since the entirety of the application is inside the package `flightControl`, let's place the package `domain` inside the package `flightControl`. Concepts of the problem domain are represented by the classes `Place`, `Airplane`, and `Flight`. +The classes that represent concepts of the problem domain are often placed inside a package called `domain`. Since the entirety of the application is inside the package `flightControl`, let's place the package `domain` inside the package `flightControl`. Concepts of the problem domain are represented by the classes `Place`, `Airplane`, and `Flight`. -The application logic is typically kept separate from the classes that represents concepts of the problem domain. In our example, application logic is stored in the package `logic`. Application logic includes the functionality to add airplanes and flights, and to list them. +The application logic is typically kept separate from the classes that represents concepts of the problem domain. In our example, the application logic is stored in the package `logic`. Application logic includes the functionality to add airplanes and flights, and to list them. -The user interface is separate from the application logic and the classes that represent the problem domain. In this example the user interface is stored in the package `ui`. +The user interface is separate from the application logic and the classes that represent the problem domain. In this example, the user interface is stored in the package `ui`. -In this exercise you will implement the application that was described above. You are free to design the structure as you wish, or you can follow the structure sketched out above. The appearance of the user interface and the required commands are predefined. This exercise is worth two normal exercise points. +In this exercise, you will implement the application that was described above. You are free to design the structure as you wish, or you can follow the structure sketched out above. The appearance of the user interface and the required commands are predefined. This exercise is worth two normal exercise points. @@ -1246,11 +1246,11 @@ In this exercise you will implement the application that was described above. Yo -

In this exercise you will implement a flight control application. It is used to control the airplanes and their flight routes. The system always knows the identifier and the capacity of an airplance. The flight information consists of the used airplane, the departure airport id (e.g. HEL), and the destination airport ID (e.g. BAL).

+

In this exercise, you will implement a flight control application. It is used to control the airplanes and their flight routes. The system always knows the identifier and the capacity of an airplance. The flight information consists of the used airplane, the departure airport id (e.g. HEL), and the destination airport ID (e.g. BAL).

-There can be multpiple airplanes and flights. The same airplane can be used to make several flights. +There can be multiple airplanes and flights. The same airplane can be used to make several flights. @@ -1418,9 +1418,9 @@ Choose an action: [3] Print airplane details [x] Quit > **2** -HA-LOL (42 henkilöä) (HEL-BAL) -HA-LOL (42 henkilöä) (BAL-HEL) -G-OWAC (101 henkilöä) (JFK-BAL) +HA-LOL (42 passengers) (HEL-BAL) +HA-LOL (42 passengers) (BAL-HEL) +G-OWAC (101 passengers) (JFK-BAL) Choose an action: [1] Print airplanes @@ -1447,7 +1447,8 @@ Choose an action: -**NB** don't use scandic letters (å, ä, ö) in the class names, since they might cause probelms with the tests! +