Tải bản đầy đủ (.pdf) (27 trang)

object oriented programming project report collecting vietnam tourism data

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (4.38 MB, 27 trang )

<span class="text_page_counter">Trang 1</span><div class="page_container" data-page="1">

<b>School of Information and Communication Technology</b>

<b>Class: 131118Teacher: Trinh Tuan Dat</b>

</div><span class="text_page_counter">Trang 3</span><div class="page_container" data-page="3">

In the course OOP, we have studied a lot about Object Oriented Programming theory, including UML diagram, java basics, exceptions, javafx , the four principles of OOP :encapsulation, abstraction, inheritance, and polymorphism , and so on.

In this report, we present the Collecting Vietnam Tourism Data problem and propose some “OOP” way for solving this problem. We will also concentrate on explaining in detail how each part of the program works and how it interacts with each other.

</div><span class="text_page_counter">Trang 4</span><div class="page_container" data-page="4">

1.Presentation of the subject

*Aims:

-The aim of the program is to collect tourism data from tourism websites and store the data in files using the turtle format. Each topic needs to be stored in separate files.

*Some knowledge used:

-Sparql Query: SPARQL is the standard query language and protocol for Linked Open Data and RDF databases. Having been designed to query a great variety of data, it can efficiently extract information hidden in non-uniform data and stored in various formats and sources.

-Library Apache Jena: A free and open-source Java framework for building Semantic Web and Linked Data applications

-DBPedia: a crowd-sourced community effort to extract structured content from the information created in various Wikimedia projects

</div><span class="text_page_counter">Trang 5</span><div class="page_container" data-page="5">

● First you download our project and open it inside your Eclipse IDE. Our project isa Maven project so it will have a file named pom.xml.

● Open file pom.xml, make sure it has this part

</div><span class="text_page_counter">Trang 6</span><div class="page_container" data-page="6">

● Right click on the VnTourism (the project name) then choose Run As-> Maven build. Now you have installed all the dependencies you need.

● Now you have to apply the JavaFx to our project

- To do this, you can watch this video here and follow its instructionJavaFX install & setup (Eclipse) � by youtuber Bro Code

● After installing the JavaFx, now you can run our project without any bugs.

</div><span class="text_page_counter">Trang 7</span><div class="page_container" data-page="7">

3. Description of the problem

3.1 Use case diagram, package diagram and class diagram.*Use case diagram:

- In our program, when user wants to collect data, the program will collect all the data related to it from DBPedia, store it in a .ttl (we name it with prefix rawRDF). For example, when we want to collect data about Lakes in Vietnam, we will collect all data about Lake from DBPedia and store it in rawRDF_Lake.ttl

- After that, we extract the data we need to Lake.ttl then we delete rawRDF_Lake.ttl.*Package diagram :

</div><span class="text_page_counter">Trang 9</span><div class="page_container" data-page="9">

<b>+ createSparqlQuery(): create sparql query to query data.</b>

<b>+ createFileName(): create a file name of the information we want to get.</b>

<b>+ createRawFileName(): create a file name for the whole data we query from the internet </b>

</div><span class="text_page_counter">Trang 10</span><div class="page_container" data-page="10">

+In each class from class TouristAttraction to last subclass there are corresponding attributes and

<b>the method overridden createSparqlQuery() .For example, in class TouristAttraction:</b>

+ Each attribute will be initialized in the constructor with the information we want to query,and will be used inside the sparql query.

+ Getters

</div><span class="text_page_counter">Trang 12</span><div class="page_container" data-page="12">

<b>+ Prefix.java declares all prefixes of SPARQL will be used in the Sparql query in the </b>

whole program.

3.3 Detailed description of front end

To implement UI for our program, we use JavaFx.

We use Grid Pane layout to design the UI; ComboBox, Button, ToggleButton and RadioButton elements are used to show available choices that user can pick. ToggleGroup is used to group therelevant RadioButton and ToggleButton elements.

</div><span class="text_page_counter">Trang 13</span><div class="page_container" data-page="13">

Anytime a user wants to quit the application, the user clicks on the “Exit” button.

To get started, users will click on the “Tourist Attraction” option. When the “Tourist Attraction” option is clicked, the “All” option is selected by default and the “Get” button is enabled.

<i>Figure 2: "Tourist Attraction" option is selected</i>

The reason we set two buttons “All” and “Detail” is to simulate the inheritance relation between the classes we implement in our program. “Tourist Attraction” is the parent class of all other classes.

Choosing “All” will collect all the data about every attraction from the database.

</div><span class="text_page_counter">Trang 14</span><div class="page_container" data-page="14">

If user wishes to choose a more specific kind of attraction, click “Detail”

<i>Figure 3: "Detail" option is selected</i>

We have 2 sub-categories: Man-made attraction and Natural Attraction. Selecting any option of these will show up the “All” and “Detail” button, like the “Tourist Attraction” option, and disablethe “Get” button.

The “Get” button will be enabled again when user choose an option

<i>Figure 4:"Natural Attraction" is selected, with "Detail" chosen</i>

If the “All” option is selected, data about <b>all </b>natural attractions or man-made attractions will be collected. Otherwise, when “Detail” is selected, a ChoiceBox element will show up. Users can specify the choice here.

Here is the available options for the sub-categories:

</div><span class="text_page_counter">Trang 16</span><div class="page_container" data-page="16">

is shown.

<i>Figure 7:"Modern Architecture" option selected</i>

Similarly, if the user chooses the “Body of Water” option in natural attraction, another ChoiceBox is shown.

</div><span class="text_page_counter">Trang 17</span><div class="page_container" data-page="17">

When the user makes his choice and clicks “Get”, a confirmation dialog will show.

</div><span class="text_page_counter">Trang 18</span><div class="page_container" data-page="18">

Click “Cancel” will return to the main menu.

When the user chooses “OK”, the collect process will start. A dialog will show the output of the process.

</div><span class="text_page_counter">Trang 19</span><div class="page_container" data-page="19">

When the process is completed successfully, a dialog will show.

</div><span class="text_page_counter">Trang 20</span><div class="page_container" data-page="20">

Users can see the output in the text area.

If the process fails, a dialog will show to inform the user that the task is not successful.For each element, we have set the corresponding listener and handler so that the proper choice will be shown/hidden/enabled/disabled.

</div><span class="text_page_counter">Trang 21</span><div class="page_container" data-page="21">

4. OOP techniques used in the program

4.1 Abstraction:

=> It reduces the complexity of viewing things.=> Avoids code duplication and increases reusability.

=> Helps to increase the security of an application or program as only essential details are provided to the user.

=> It improves the maintainability of the application4.2 Encapsulation:

● Data/attributes and behaviors/methods are encapsulated in a class

● Every single class in package <b>touristattraction</b> follows this rule. For example, in the class TouristAttraction:

</div><span class="text_page_counter">Trang 22</span><div class="page_container" data-page="22">

=> Protects an object from unwanted access=>Simplifies the maintenance of the application.=> Makes the application easier to understand.4.3 Data hiding

- All the attributes in classes in package <b>touristattraction </b>are private =>can only be accessed and modified through getters and setters

- For example, in the class TouristAttraction:

</div><span class="text_page_counter">Trang 23</span><div class="page_container" data-page="23">

=> ensures exclusive data access to class members and protects object integrity by preventing unintended or intended changes

</div><span class="text_page_counter">Trang 24</span><div class="page_container" data-page="24">

=> store the variable we have to reuse many times in the project.4.5 Variable arguments

- In interface IDataProcess,we use this technique

=> To pass an arbitrary number of arguments4.6 Utility classes in Java

- In class App, we have used Number class

=>To use all the functions Java has had.

</div><span class="text_page_counter">Trang 25</span><div class="page_container" data-page="25">

<b>We have the diagram of package touristattraction.</b>

=>Code reuse

=> Provides a clear model structure which is easy to understand.

4.8 JavaFX

- You can check class <b>App </b>to see the JavaFx Application we have created

4.9 Catching and handling exceptions, nested try – catch blocks

- In interface IDataProcess, we have use try ... catch ... finally to handle the exceptions

</div><span class="text_page_counter">Trang 26</span><div class="page_container" data-page="26">

<b> 4.10 Generic programming: using Wildcard</b>

- In class <b>App</b>

=> Elimination of casts

5.Conclusion and further discussions

-So, with the help of OOP, we have finished the assignment. Thanks to the hard work of the team, we have done quite well, though there are a lot more needed to be done. We have learned to use a lot of techniques in OOP, how to model a program so that it can run better.

- In the future, we can upgrade our program to make it better. This can be done with ease since our model follows high cohesion and loose coupling. In the future, our team will keep enhancing this program. Special thanks to Mr Trinh Tuan Dat for helping us with OOP lectures.

</div><span class="text_page_counter">Trang 27</span><div class="page_container" data-page="27">

6. Task contribution:

6.1 Programming tasks:

- Modelling the project, the logic of code: Đỗ Tuấn Minh-Code package backend:

+Code package rdfconstant, dataprocess: Đỗ Tuấn Minh

+Code package touristattraction: Đỗ Tuấn Minh, Nguyễn Phương Quang-Code package frontend : Nguyễn Hoàng Hải

6.2 Other tasks:

- Create use case diagram: Đỗ Tuấn Minh

- Create package diagram, class diagram: Nguyễn Hoàng Hải- Write the report:

+ 1,2,3.1,4,6: Đỗ Tuấn Minh+ 3.2: Nguyễn Phương Quang+ 3.3: Nguyễn Hoàng Hải

- Formatting the report: Nguyễn Kim Tuyến- Demo video: Đỗ Tuấn Minh

- Make the powerpoint: Nguyễn Phương Quang- Presenter: Đỗ Tuấn Minh

7. List of bibliographic reference:

-

×