DESIGN AND IMPLEMENTATION OF A PUZZLE GAME USING JAVA SE 1. University Politehnica Timisoara, Faculty Engineering Hunedoara, ROMANIA

Similar documents
DEVELOPMENT OF AN INTERACTIVE ENVIRONMENT USED FOR SIMULATION OF SHORTEST PATHS ALGORITHMS

Educational Software for Teaching the Basics of Computer Science

The class definition is not a program by itself. It can be used by other programs in order to create objects and use them.

Educational soft presenting particularities through special functions of ABAP List Viewer in Web Dynpro technology

Graphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub

Today s Topic. Lecture 5. What is UML? Why Use UML. UML Diagrams. Introduction to UML. What is UML Why use UML? UML Diagrams

Software Engineering with Objects and Components 1 Overview

Level: M.Ed. Credit Hour: 3 (2+1) Semester: Second Teaching Hour: 80(32+48)

STUDY ABOUT OBJECT ORIENTED MODELING

* To change this license header, choose License Headers in Project Properties.

Computer Science II. OO Programming Classes Scott C Johnson Rochester Institute of Technology

Information systems design: a procedural approach

Java Swing Introduction

MONITORING MASS CUSTOMIZATION AND OPEN INNOVATION ON THE WORLD WIDE WEB: A USAGE ANALYSIS Ashcroft Instruments GmbH, GERMANY

Introduction to Software Engineering: Analysis

ArchiMate symbols for relating system elements

Hanley s Survival Guide for Visual Applications with NetBeans 2.0 Last Updated: 5/20/2015 TABLE OF CONTENTS

Course 3 7 March

Prime Generating Algorithms by Skipping Composite Divisors

ACTA TECHNICA CORVINIENSIS Bulletin of Engineering Tome X [2017] Fascicule 2 [April June] ISSN:

Automatic Generating UML Use Case Diagram and Test Cases Based on Classification Tree Method

Teaching Object-Oriented Systems Analysis and Design with UML

to schedule pressure

Software Modelling. UML Class Diagram Notation. Unified Modeling Language (UML) UML Modelling. CS 247: Software Engineering Principles

CS 247: Software Engineering Principles. UML Modelling

CSC207 Week 2. Larry Zhang

Classes and Objects 3/28/2017. How can multiple methods within a Java class read and write the same variable?

Goals. Lecture 7 More GUI programming. The application. The application D&D 12. CompSci 230: Semester JFrame subclass: ListOWords

PROGRAMMING FUNDAMENTALS

* To change this license header, choose License Headers in Project Properties.

CS111: PROGRAMMING LANGUAGE II. Lecture 1: Introduction to classes

REVIEW AND OUTLOOKS OF THE MEANS FOR VISUALIZATION OF SYNTAX SEMANTICS AND SOURCE CODE. PROCEDURAL AND OBJECT ORIENTED PARADIGM DIFFERENCES

CSCI 201L Midterm Written Summer % of course grade

Java Programming Summer 2008 LAB. Thursday 8/21/2008

The Unified Modeling Language (UML)

Generating Programs with Grammars and ASTGen

SOME ONTOLOGICAL ISSUES OF THE REA FRAMEWORK IN RELATION TO ENTERPRISE BUSINESS PROCESS

Chapter 4 Defining Classes I

San Jose State University College of Science Department of Computer Science CS151, Object-Oriented Design, Sections 1,2 and 3, Spring 2017

Chapter 4 Requirements Elicitation

3D MODELLING OF A SHRINK FITTED CONCAVE ENDED CYLINDRICAL TANK FOR AUTOMOTIVE INDUSTRY

Separation of Transitions, Actions, and Exceptions in Model-based Testing

Object-Oriented Software Engineering Re-exam, 2012 (Also Object-Oriented Analysis, Design and Programming, Re-exam, 2012)

Strings and Loops CSE moodle.yorku.ca. moodle.yorku.ca CSE 1020

Object-Oriented Software Development Goal and Scope

LESSON PLAN SUB NAME : OBJECT ORIENTED ANALYSIS AND DESIGN UNIT SYLLABUS

Utilization of UML diagrams in designing an events extraction system

System Structure Modeling

International Journal of Advance Engineering and Research Development. Leaking in Java

Praktische Softwaretechnologie

A - 1. CS 494 Object-Oriented Analysis & Design. UML Class Models. Overview. Class Model Perspectives (cont d) Developing Class Models

Answer on question #61311, Programming & Computer Science / Java

E-BOOK JAVA DIAGRAM FRAMEWORK ARCHIVE

Tutorial 2 Today we will have a quick introduction to ArgoUML and how to use it, as well as look at some examples of class diagrams.

Research Article A Design Pattern Approach to Improve the Structure and Implementation of the Decorator Design Pattern

DAFTAR LAMPIRAN. Source Code Java Aplikasi Keyword to Image Renamer Split

Introduction to Information Systems (IS)

The most common relationships are: dependency, association, generalization, and realization.

Chapter 2, Modeling with UML: UML 2 Hightlights

Unified Modeling Language

Java Fundamentals (II)

Subclass Gist Example: Chess Super Keyword Shadowing Overriding Why? L10 - Polymorphism and Abstract Classes The Four Principles of Object Oriented

Midterm assessment - MAKEUP Fall 2010

Object Oriented Programming. Michał Bereta

Multithreading Pearson Education, Inc. All rights reserved.

Control Statements: Part Pearson Education, Inc. All rights reserved.

Keywords: Teaching with analogy; analogy in textbook; mathematics education; teaching geometry; secondary education.

AN AGENT BASED INTELLIGENT TUTORING SYSTEM FOR PARAMETER PASSING IN JAVA PROGRAMMING

Software Engineering

Software Design And Modeling BE 2015 (w. e. f Academic Year )

Lecture 1 - Introduction (Class Notes)

Generic and Domain Specific Ontology Collaboration Analysis

Systems Programming. Bachelor in Telecommunication Technology Engineering Bachelor in Communication System Engineering Carlos III University of Madrid

S T R U C T U R A L M O D E L I N G ( M O D E L I N G A S Y S T E M ' S L O G I C A L S T R U C T U R E U S I N G C L A S S E S A N D C L A S S D I A

Using Conceptual Analysis in Java Environment for the X-Ray view on a Class

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Birkbeck (University of London) Software and Programming 1 In-class Test Mar 2018

ERRDS: A CASE TOOL TO GENERATE AN ER DATA MODEL FROM A RELATIONAL DATABASE SCHEMA

State Pattern supporting both composite States and extension/specialization of State Machines

A Method for Conceptual Modeling of Semantically Integrated Use-case Scenarios

Java: Classes. An instance of a class is an object based on the class. Creation of an instance from a class is called instantiation.

Me4DCAP V0.1: a method for the development of Dublin Core Application Profiles

Release of Octopus/UML

Week 9 Implementation

Details of Class Definition

Chapter 1. Preliminaries

What are the characteristics of Object Oriented programming language?

System Architecture Design

Oracle 1z Java Standard Edition 5 Programmer Certified Professional Upgrade Exam. Practice Test. Version:

Unified Modeling Language

/** Creates new form NewJFrame */ public NewJFrame() { initcomponents(); initblogsearch(); //initializes Index List box }

CS/B.TECH/CSE(New)/SEM-5/CS-504D/ OBJECT ORIENTED PROGRAMMING. Time Allotted : 3 Hours Full Marks : 70 GROUP A. (Multiple Choice Type Question)

CHAPTER 1 Introduction to Computers and Java

Towards a Java Framework for Knowledge Representation and Inference

P2: Exercise 2 Discussion. Pooja Rani

Exam Questions 1Z0-850

MSc programme (induction week) Department of Informatics INTRODUCTION TO UML

Introduction to OO Concepts

Me4DCAP V0.1: A method for the development of Dublin Core Application Profiles

Index. Add Diagram > Sequence Diagram command,

Transcription:

ANNALS of Faculty Engineering Hunedoara International Journal of Engineering Tome XV [2017] Fascicule 3 [August] ISSN: 1584-2665 [print; online] ISSN: 1584-2673 [CD-Rom; online] a free-access multidisciplinary publication of the Faculty of Engineering Hunedoara 1. Anca-Elena IORDAN DESIGN AND IMPLEMENTATION OF A PUZZLE GAME USING JAVA SE 1. University Politehnica Timisoara, Faculty Engineering Hunedoara, ROMANIA Abstract: In this article are rendered the requisite stages for the accomplishment of a puzzle game. The puzzle consists in moving the polyhedra of different types and colours, having five levels of difficulty. It can choose from three types of polyhedra: prisms, pyramids or pyramidal frustums. The game is ended when on every line the polyhedra have the same colour and on every column have the same polygon as base in an increasing number of sides of the base. The design of the puzzle is accomplished by the next UML diagrams: use-case diagram, class diagram and component diagram. By achieving these types of diagrams, the puzzle is described in an obvious and concrete approach, without ambiguousness. The implementation of the game was realised through the Java programming language with NetBeans IDE. The game also allows the determination of the optimal solution by implementing of A* informed search algorithm using Manhattan admissible heuristic function. Keywords: Puzzle, UML, ArgoUML, Java, NetBeans IDE, A* algorithm 1. INTRODUCTION The puzzle game presented consists in a number of polyhedra of different types and colours that can be moved using the free available spaces. The problem requires to be found the movements in order the game starts from an initial configuration and reaches to a determined configuration. The puzzle has the option for choosing from three types of polyhedra: prisms, pyramids or pyramidal frustums. The difficulty of puzzle depends by the number of the used colours. The game is ended when on every line the polyhedra have the same colour and on every column have the same polygon as base in an increasing number of sides of the base. The game also allows the determination of the optimal solution by implementing of A* heuristic algorithm [1]. Because the problem is enough complex, the principal difficulty in solving it is given by dimension of search space, that leads to necessity of a heuristic search [2]. 2. THE ANALYSIS OF THE PUZZLE From the perspective of unified modelling language, the analysis of puzzle application includes the representation of the use-case diagram. The use-case diagram [3, 4] offers simplified and graphical representation of what the puzzle game must really do. Use-case diagram is based upon functionality and thus will focus on the what offers the game and not the how will be realized. The use case diagram corresponding to this puzzle software, presented in figure 1, includes: One actor - the user who is external entity with that the puzzle game interacts. Seven use-cases which describe the performance of the game. Figure 1. Use-case diagram Relationships between user and use-cases (association relationships), and relationships between usecases (dependency and generalization relationships). 235 F ascicule 3

3. THE DESIGN OF THE PUZZLE Conceptual modelling allows identifying the very important elements for the interactive software [5, 6]. Class diagram is represented in figure 2 in order to be observed the connection mode between the classes and the interfaces that are used and also the composition and aggregate relationships between instances. After identifying the specific elements of the puzzle, they were been implemented 7 interfaces and 16 classes grouped into three packages. Package geometrie brings together concepts that correspond to the polyhedra used by puzzle, consisting of 8 classes and one interface. Of the eight classes, three are abstract classes. Package algoritm brings together concepts that correspond to the A* heuristic algorithm, consisting of 6 classes and 5 interfaces. For memorizing a state configuration, there was implemented Stare3D class which implements Stare interface. For memorizing a node of search tree, it was implemented Nod_Puzzle class which realizes Nod interface and for memorizing an expanded node together with its successors, it was implemented Nod_Expandat_Puzzle class which realizes Nod_Expandat interface. A* heuristic search algorithm is implemented by using Algoritm_A_Stea_Puzzle class. An instance of this class is composed by two instances of Nod_Puzzle class, according to composition relationship which exists in diagram, but can also contain instances of Nod_Expandat_Puzzle class, as it can be observed from aggregate relationship presented in diagram. Package gui brings together concepts that correspond to the graphical user interface, consisting of 2 classes and one interface. For designing the graphical interface of the game, it was implemented the Puzzle class. It can observe that this class implements the Runnable interface. An instance of this class is composed by one instance of Suprafata3D class, but can also contain instances of Algoritm_A_Stea_Puzzle and Nod_Puzzle classes, as it can be observed from aggregate relationship presented in diagram. 4. THE IMPLEMENTATION OF THE PUZZLE The component diagram [7, 8] enables the visualization modules that compose the software and the dependencies between them. The diagram that is shown in figure 2 describes the collection of components that all together ensure the functionality of the puzzle game. Central component of the diagram is Puzzle.class, a component obtained by transforming by the Java compiler into executable code of the Puzzle.java component. As can be seen that component interacts directly with components Suprafata3D.class. 5. GRAPHICAL USER INTERFACE The puzzle game is accomplished using the Java object-oriented programming language [9, 10, 11].Given that specified requisites in Figure 2. Class diagram uses cases diagram (figure 1) it was designed graphical user interface of the puzzle. In figures 4 and 5 are presented the five levels of difficulty. In figure 6 is presented the corresponding final state of the third level of difficulty. The structure of the class corresponding to the graphical interface is presented in the following: public class PUZZLE extends java.awt.frame implements Runnable { SUPRAFATA3D s3; Thread fir; LinkedList<NOD_PUZZLE> solutie_optima; public PUZZLE() { public void actualizarenrmutari(int nr) { private void initcomponents(){ private void exitform(windowevent evt){ private void nouactionperformed(actionevent evt){ 236 F ascicule 3

private void nivelstatechanged(changeevent evt){ private void ajutoractionperformed(actionevent evt) { private void prismaactionperformed(actionevent evt) { private void piramidaactionperformed(actionevent evt){ private void trunchiactionperformed(actionevent evt) { private void optimactionperformed(actionevent evt) { private void nousimpluactionperformed(actionevent evt) { public static void main(string args[]) { private javax.swing.jbutton ajutor; private javax.swing.jlabel l1; private javax.swing.jlabel l3; private javax.swing.jlabel l4; private javax.swing.jtextfield mutare; private javax.swing.jspinner nivel; private javax.swing.jbutton nou; private javax.swing.jbutton nousimplu; private javax.swing.jbutton optim; private javax.swing.jradiobutton piramida; private javax.swing.buttongroup poliedru; private javax.swing.jpanel principal; private javax.swing.jradiobutton prisma; private javax.swing.jradiobutton trunchi; Figure 3. Component diagram Figure 4. First three levels of difficulty 237 F ascicule 3

Figure 6.Corresponding final state to Figure 5. Last two levels of difficulty the third level of difficulty By selecting the button OPTIMAL SOLUTION is instancing an object of Algoritm_A_Stea_Puzzle class which permits the determination of the optimal solution by running of the A* heuristic algorithm. In figure 7 is presented the result returned by this algorithm for an example. The structure of the class corresponding to the A* heuristic algorithm is presented in the following: public class ALGORITM_A_STEA_PUZZLE implements ALGORITM_A_STEA { private NOD_PUZZLE si; private final NOD_PUZZLE sf; private LinkedList<NOD_PUZZLE> frontiera; private LinkedList<NOD_EXPANDAT_PUZZLE> teritoriu; private LinkedList<NOD_PUZZLE> solutie; private long nr; private Vector<String> concluzie; Figure 7. Optimal solution private LinkedList<NOD_PUZZLE> succesori; public ALGORITM_A_STEA_PUZZLE(STARE3D s1) { public LinkedList<NOD_PUZZLE> getfrontiera() { public LinkedList<NOD_EXPANDAT_PUZZLE> getteritoriu() { public LinkedList<NOD_PUZZLE> getsolutie() { public LinkedList<NOD_PUZZLE> getsuccesori() { public Vector<String> getconcluzie() { public void setfrontiera(linkedlist<nod_puzzle> L) { public void setteritoriu(linkedlist<nod_expandat_puzzle> L) { public void initializare() { public LinkedList<NOD_PUZZLE> generaresuccesori(nod_puzzle opt) { public void algoritm() { public NOD_PUZZLE optim() { public int apartine(nod_puzzle s, LinkedList<NOD_PUZZLE> L) { public void inserare(nod_puzzle s) { public void solutie(nod_puzzle O) { public void setaresuccesori(int p, NOD_PUZZLE np) { The structure of the NOD_PUZZLE class is presented in the following: public class NOD_PUZZLE implements NOD { private STARE_PUZZLE stare; private NOD_PUZZLE predecesor; private int f; private int g; private int h; public NOD_PUZZLE() { public NOD_PUZZLE(STARE3D s) { public NOD_PUZZLE(STARE3D s, NOD_PUZZLE p) { public NOD_PUZZLE(NOD_PUZZLE S) { public void setare(stare3d s,nod_puzzle p,int f1,int g1,int h1) { public void setstare(stare3d s) { public void setpredecesor(nod_puzzle p) { public void setf(int f1) { public void setg(int g1) { public void seth(int h1) { 238 F ascicule 3

public int getf() { public int getg() { public int geth() { public STARE_PUZZLE getstare() { public NOD_PUZZLE getpredecesor() { public void F() { public void G() { public void H() { public boolean egal(object S1) { public String tostring() { The structure of the NOD_EXPANDAT_PUZZLE class is presented in the following: public class NOD_EXPANDAT_PUZZLE implements NOD_EXPANDAT { private NOD_PUZZLE expandat; private LinkedList<NOD_PUZZLE> succesori; public NOD_EXPANDAT_PUZZLE() { public NOD_EXPANDAT_PUZZLE(NOD_PUZZLE n) { public NOD_EXPANDAT_PUZZLE(NOD_EXPANDAT_PUZZLE n) { public void setnodexpandat(nod_puzzle n) { public void setsuccesori(linkedlist<nod_puzzle> L) { public void adaugsuccesor(nod_puzzle n) { public int getnrsuccesori() { public NOD_PUZZLE getsuccesor(int i) { public LinkedList<NOD_PUZZLE> getsuccesori() { public NOD_PUZZLE getnodexpandat() { public void generaresuccesori() { 6. CONCLUSIONS Because the representation of the diagrams corresponding to all three phases: analysis, design and implementation, the puzzle game has been described in an obvious and objective manner, without ambiguity. The use of the unified modelling language for the achievement of the diagrams is characterized by rigorous syntactic, rich semantic and visual modelling support. References [1.] W. Ertel, Introduction to Artificial Intelligence, Springer-Verlag, Berlin, 2011 [2.] Z. Shi, Advanced Artificial Intelligence, Word Scientific Publishing, 2011 [3.] P. Jalote, A Concise Introduction to Software Engineering, Springer-Verlag, 2008 [4.] M. Fowler, K. Scott, UML Distilled: A Brief Guide to the Standard Object Modelling Language, Pearson Education, 2003 [5.] J. Hunt, Guide to the Unified Process featuring UML, Java and Design Patterns, Springer London Ltd, 2014 [6.] K. Lunn, J. Skelton, S. Bennett, Schaum s Outline of UML, McGraw-Hill Education, 2004 [7.] B. Bruegge, A. Dutoit, Object Oriented Software Engineering Using UML, Patterns, and Java, Pearson Education, 2013 [8.] A. Dennis, B. H. Wixom, D. Tegarden, Systems Analysis and Design with UML, John Wiley & Sons Ltd, 2012 [9.] R. Martin, Java Application Architecture, Pearson Education, 2012 [10.] J. Bryant, Java 7 for Absolute Beginners, Springer, 2012 [11.] J. Gosling, B. Joy, G. Steele, G. Bracha, A. Buckley, The Java Language Specification, Oracle, 2013 ANNALS of Faculty Engineering Hunedoara International Journal of Engineering copyright UNIVERSITY POLITEHNICA TIMISOARA, FACULTY OF ENGINEERING HUNEDOARA, 5, REVOLUTIEI, 331128, HUNEDOARA, ROMANIA http://annals.fih.upt.ro 239 F ascicule 3