AI/ES (Artificial Intelligence / Expert System) Visual Prolog: Part 4

Slides:



Advertisements
Similar presentations
AI/ES (Artificial Intelligence / Expert System) Visual Prolog: Part 2
Advertisements

AI/ES (Artificial Intelligence / Expert System) Visual Prolog: Part Fall. SME., Pukyong Nat l Univ. Kim, Minsoo.
Introduction to Visual Basic.NET Uploaded By: M.Sheraz anjum.
Python Objects and Classes
Object-Oriented programming in C++ Classes as units of encapsulation Information Hiding Inheritance polymorphism and dynamic dispatching Storage management.
Prolog.
Module 8 “Polymorphism and Inheritance”. Outline Understanding Inheritance Inheritance Diagrams Constructors in Derived Classes Type Compatibility Polymorphism.
Chapter 1 Object Oriented Programming. OOP revolves around the concept of an objects. Objects are crated using the class definition. Programming techniques.
More about classes and objects Classes in Visual Basic.NET.
© 2006 Pearson Addison-Wesley. All rights reserved4-1 Chapter 4 Data Abstraction: The Walls.
Creating Object Oriented Programs Object oriented (OO) terminology Class vs. object Instantiate an object in a project Understand Class_Initialize / Terminate.
© 2006 Pearson Addison-Wesley. All rights reserved4-1 Chapter 4 Data Abstraction: The Walls.
ASP.NET Programming with C# and SQL Server First Edition
Chapter 13: Object-Oriented Programming
C++ fundamentals.
OOP Languages: Java vs C++
JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2008 Pearson Education, Inc., Upper.
UFCEUS-20-2 : Web Programming Lecture 5 : Object Oriented PHP (1)
Programming Languages and Paradigms Object-Oriented Programming.
CSM-Java Programming-I Spring,2005 Introduction to Objects and Classes Lesson - 1.
O BJECT O RIENTATION F UNDAMENTALS Prepared by: Gunjan Chhabra.
CSM-Java Programming-I Spring,2005 Objects and Classes Overview Lesson - 1.
Introduction to Graphical User Interfaces. Objectives * Students should understand what a procedural program is. * Students should understand what an.
Introduction to Object Oriented Programming. Object Oriented Programming Technique used to develop programs revolving around the real world entities In.
AI/ES (Artificial Intelligence / Expert System) Visual Prolog: Part Fall. SME., Pukyong Nat ’ l Univ. Kim, Minsoo.
AI/ES (Artificial Intelligence / Expert System) Visual Prolog: Part Fall. SME., Pukyong Nat ’ l Univ. Kim, Minsoo.
Chapter 8: Writing Graphical User Interfaces
1 1 Lab1 Ismail M. Romi – IT Dept, PPU, Visual Basic 2005 Programming Tour.
Programming in Java Unit 2. Class and variable declaration A class is best thought of as a template from which objects are created. You can create many.
Chapter 6 Object-Oriented Java Script JavaScript, Third Edition.
1 Chapter 8 – Classes and Object: A Deeper Look Outline 1 Introduction 2 Implementing a Time Abstract Data Type with a Class 3 Class Scope 4 Controlling.
Chapter 1 Object Oriented Programming. OOP revolves around the concept of an objects. Objects are created using the class definition. Programming techniques.
Sadegh Aliakbary Sharif University of Technology Spring 2011.
1 Programming Paradigms Object Orientated Programming Paradigm (OOP)
Programming in Java CSCI-2220 Object Oriented Programming.
Chapter 6 Introduction to Defining Classes. Objectives: Design and implement a simple class from user requirements. Organize a program in terms of a view.
Nyhoff, ADTs, Data Structures and Problem Solving with C++, Second Edition, © 2005 Pearson Education, Inc. All rights reserved More about.
Java Basics Opening Discussion zWhat did we talk about last class? zWhat are the basic constructs in the programming languages you are familiar.
Classes. Constructor A constructor is a special method whose purpose is to construct and initialize objects. Constructor name must be the same as the.
Salman Marvasti Sharif University of Technology Winter 2015.
Visual Basic for Application - Microsoft Access 2003 Programming applications using Objects.
 Objects versus Class  Three main concepts of OOP ◦ Encapsulation ◦ Inheritance ◦ Polymorphism  Method ◦ Parameterized ◦ Value-Returning.
Object Oriented Programing (OOP)
Chapter 4 Generic Vector Class. Agenda A systemic problem with Vector of Object – Several approaches at a solution – Generic structures Converting classes.
Peyman Dodangeh Sharif University of Technology Spring 2014.
11 Introduction to Object Oriented Programming (Continued) Cats.
JAVA: An Introduction to Problem Solving & Programming, 6 th Ed. By Walter Savitch ISBN © 2012 Pearson Education, Inc., Upper Saddle River,
C# Fundamentals An Introduction. Before we begin How to get started writing C# – Quick tour of the dev. Environment – The current C# version is 5.0 –
Nyhoff, ADTs, Data Structures and Problem Solving with C++, Second Edition, © 2005 Pearson Education, Inc. All rights reserved More about.
Import existing part with drawing
OBJECT ORIENTED PROGRAMMING
Data Abstraction: The Walls
Intro To Classes Review
OOP What is problem? Solution? OOP
Microsoft Visual Basic 2005: Reloaded Second Edition
Object-Orientated Programming
More about OOP and ADTs Classes
Advanced Programming Behnam Hatami Fall 2017.
النظم الخبيرة Expert Systems (ES)
Programming in Java Text Books :
CIS16 Application Development Programming with Visual Basic
More about OOP and ADTs Classes
Dynamic Data Structures and Generics
Lecture Set 11 Creating and Using Classes
Chapter 6: Programming Languages
Introduction to Data Structure
These slides are for reference only. They are not "lecture notes"
Object-Oriented PHP (1)
2.1 Introduction to Object-Oriented Programming
C++ data types.
Presentation transcript:

AI/ES (Artificial Intelligence / Expert System) Visual Prolog: Part 4 2012. Fall. SME., Pukyong Nat’l Univ. Kim, Minsoo

Contents Classes and Objects Classes and Modules Holding Objects

Classes and Objects The world of object orientation The world consists of identifiable objects. Person, Cat, Dog, … An object has certain characteristics(attributes). Person: name, length, weight, iq, … Objects can do something (tasks). Operations / methods Person: run, smile, talk, … The set of objects with the same operations and attributes  class Jack, Linda, John, …  Person Objects are related to each other.

Classes and Objects Class vs. Object Class: User-Defined Type(Domain) Template for object creation  new() constructor Manager for member object  class predicates/facts Instance Object: created individual thing With different identity With same attributes and methods Person "John", 85, 185, 110 NumberOfPerson "Thomas", 78, 190, 150 Name Age Length Weight "Anna", 65, 175, 130 "Lidy", 55, 160, 123 NumberOfPerson = 4

Classes and Objects OOP in Visual Prolog Class file(*.cl): declaration of public method class-wide predicates and facts Interface file(*.i): declaration of public method Instance object’s predicates and facts Prolog file (*.pro): actual implementation Actual implementation of public method Private method declaration and implementation Person getNumberOfPerson() … getNumberOfPerson() :- … getName() :- setName(string Name) :- NumberOfPerson person.cl Name Age Length Weight getName() setName(string Name) … person.i person.pro

Classes and Objects Create a project ‘ch08class’ Add ‘person’ class to the project Check ‘Create Interface’

Classes and Objects Build up ‘person’ class In the ‘person.i‘ file, add 2 predicates Add constructor to the ‘person.cl’ file + person type +

Classes and Objects Add implementation to ‘person.pro’ file, Build! + lowercase identifier + constructor member assignment

Classes and Objects Add menu/menu-item and connect TaskMenu.mnu  Object/CreatObject TaskWindow.win  onObjectCreateObject

Classes and Objects Build / Try Press <F5> if there’s an error.

Classes and Objects Add Dialog to create ‘person’ object Create a package named ‘uiForms’ Create ‘createPerson’ dialog under uiForms

Classes and Objects Edit ‘createPerson‘ dialog Add ClickResponder to createObject_ctl name_ctl createObject_ctl

Classes and Objects In the TaskWindow.win  change the code in ‘onObjectCreateObject’ clause

Classes and Objects Build  Run add a line to constructor in ‘person.pro’ file. Build  Run

Classes and Objects Add class predicate to person class Declare class predicate at the ‘person.cl’ file. +

Classes and Objects Add implementation to ‘person.pro’  Run! +

Classes and Modules Module: non-object constructing class Just a collection of class predicates. No interface file is created for module. Add ‘output.cl’ class to the project. Uncheck ‘Create Interface’ option

Classes and Modules Add predicate to ‘output.cl’ file. No type definition in the ‘output.cl’ file. No type for output + Overloading, Polymorphism

Classes and Modules Add implementation to ‘output.pro’ file. +

Classes and Modules Build / Run! Change constructor in the ‘person.pro’ file. Build / Run!

Holding Objects Garbage Collection Add 3 more menu options Unreferenced object’s memory is reclaimed. Keep the object reference for it being reachable. Add 3 more menu options

Holding Objects Edit ‘person.pro’ file. + +

Holding Objects Edit ‘person.pro’ file. (continued) + +

Holding Objects Build / Run! Add declaration to ‘person.i’ file. Test ‘Create Object’ menu item. +

Holding Objects Complete menu items Add class predicate to ‘person.cl’ file.

Holding Objects Add implementation to ‘person.pro’ file. + showAllPersons() :- stdIO::write("These are the persons in the database.\n"), showAllObjects(createdObjects). class predicates showAllObjects : (person* CreatedObjects). clauses showAllObjects([Head | Tail]) :- stdIO::write("Name: ", Head:getName(), " with Number: ", Head:getNumber()), stdIO::nl, !, showAllObjects(Tail). showAllObjects([]).

Holding Objects Add connection to menu items TaskWindow.win  ‘Show All’ and ‘Show Single’ predicates onObjectShowAll : window::menuItemListener. clauses onObjectShowAll(_Source, _MenuTag) :- person::showAllPersons(). onObjectShowSingle : window::menuItemListener. onObjectShowSingle(_Source, _MenuTag) :- person::getAllNames(NamesList), b_true = vpiCommonDialogs::listSelect("Select a name", NamesList, 0, Name, _Index), !, person::showSinglePerson(Name). onObjectShowSingle(_Source, _MenuTag) :- !. + +

Holding Objects Add declaration to ‘person.cl’ file. +

Holding Objects Add implementation to ‘person.pro’ file. + clauses getAllNames(NamesList) :- getNames(createdObjects, NamesList). class predicates getNames : (person* CreatedObjects, string* NamesList) procedure (i, o). getNames(ObjectsList, NamesList) :- [Head | Tail] = ObjectsList, !, Name = Head:getName(), getNames(Tail, TailNamesList), NamesList = [Name | TailNamesList]. getNames([], []) :- !.

Holding Objects Add implementation to ‘person.pro’ file. (cont) + clauses showSinglePerson(Name) :- getData(Name, createdObjects, Number), !, stdIO::write("You have selected: ", Name, " with number: ", Number), stdIO::nl. showSinglePerson(_Name). class predicates getData : (string Name, person* ObjectsList, unsigned Number) determ (i, i, o). getData(Name, ObjectsList, Number) :- [Head | Tail] = ObjectsList, Name <> Head:getName(), !, getData(Name, Tail, Number). getData(_Name, ObjectsList, Number) :- [Head | _] = ObjectsList, Number = Head:getNumber().

Holding Objects Add code for ‘Delete Object’ menu item. TaskWindow.win  onObjectDeleteObject clauses onObjectDeleteObject(_Source, _MenuTag) :- person::getAllNames(NamesList), b_true = vpiCommonDialogs::listSelect("Select a name", NamesList, 0, Name, _Index), !, person::deletePerson(Name). onObjectDeleteObject(_, _).

Holding Objects Add declaration to ‘person.cl’ file. +

Holding Objects Add implementation to ‘person.pro’ file. + clauses deletePerson(Name) :- [Object | Tail] = createdObjects, Name = Object:getName(), !, createdObjects := Tail, stdIO::write("Person ", Name, " has been deleted.\n"). deletePerson(Name), !, createdObjects := [Object | createdObjects]. deletePerson(_).

Holding Objects Rebuild All  Run!