Classes and objects Practice 2. Basic terms  Classifier is an element of the model, which specifies some general features for a set of objects. Features.

Slides:



Advertisements
Similar presentations
CSE 1302 Lecture 23 Hashing and Hash Tables Richard Gesick.
Advertisements

File Processing : Hash 2015, Spring Pusan National University Ki-Joune Li.
Hashing as a Dictionary Implementation
Chapter 6 Queue. Learning Objectives ● Describe the behavior of a queue. ● Enumerate the primary operations supported by a queue. ● Learn about the UNIX.
Stereotypes Stereotypes provide the capability to create a new kind of modeling element. –They can be used to classify or mark modeling elements. –A type.
File System Interface CSCI 444/544 Operating Systems Fall 2008.
BTrees & Bitmap Indexes
1 © Wolfgang Pelz UML3 UML 3 Notations describe how to use reusable software. Package Component Deployment Node.
Java Programming, 3e Concepts and Techniques Chapter 5 Arrays, Loops, and Layout Managers Using External Classes.
Sets and Maps Chapter 9. Chapter 9: Sets and Maps2 Chapter Objectives To understand the Java Map and Set interfaces and how to use them To learn about.
Java Collections. Lecture Objectives To understand the concepts of Java collections To be able to implement Java programs based on Collections.
Alice in Action with Java
Operating Systems File systems
Homework 2 In the docs folder of your Berkeley DB, have a careful look at documentation on how to configure BDB in main memory. In the docs folder of your.
Introducing Hashing Chapter 21 Copyright ©2012 by Pearson Education, Inc. All rights reserved.
Object-Oriented Analysis and Design
C o n f i d e n t i a l Developed By Nitendra NextHome Subject Name: Data Structure Using C Title: Overview of Data Structure.
Maps A map is an object that maps keys to values Each key can map to at most one value, and a map cannot contain duplicate keys KeyValue Map Examples Dictionaries:
Chapter 61 Chapter 6 Index Structures for Files. Chapter 62 Indexes Indexes are additional auxiliary access structures with typically provide either faster.
JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2008 Pearson Education, Inc., Upper.
CSE 331 Software Design & Implementation Hal Perkins Autumn 2012 Java Classes, Interfaces, and Types 1.
FEN 2012UCN Technology - Computer Science 1 Data Structures and Collections Principles revisited.NET: –Two libraries: System.Collections System.Collections.Generics.
Data Structures and Abstract Data Types "Get your data structures correct first, and the rest of the program will write itself." - David Jones.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 22 Java Collections.
Java™ How to Program, 9/e Presented by: Dr. José M. Reyes Álamo © Copyright by Pearson Education, Inc. All Rights Reserved.
111 © 2002, Cisco Systems, Inc. All rights reserved.
Object-Oriented Program Development Using Java: A Class-Centered Approach, Enhanced Edition.
Data Structure & File Systems Hun Myoung Park, Ph.D., Public Management and Policy Analysis Program Graduate School of International Relations International.
Session 08 Module 14: Generics and Iterator Module 15: Anonymous & partial class & Nullable type.
Data structures Abstract data types Java classes for Data structures and ADTs.
File Storage Organization The majority of space on a device is reserved for the storage of files. When files are created and modified physical blocks are.
Can’t provide fast insertion/removal and fast lookup at the same time Vectors, Linked Lists, Stack, Queues, Deques 4 Data Structures - CSCI 102 Copyright.
Logical view –show classes and objects Process view –models the executables Implementation view –Files, configuration and versions Deployment view –Physical.
Hashing Hashing is another method for sorting and searching data.
Hashing as a Dictionary Implementation Chapter 19.
Chapter 12 Hash Table. ● So far, the best worst-case time for searching is O(log n). ● Hash tables  average search time of O(1).  worst case search.
Hashing 8 April Example Consider a situation where we want to make a list of records for students currently doing the BSU CS degree, with each.
Chapter 11 Hash Tables © John Urrutia 2014, All Rights Reserved1.
Object Oriented Analysis and Design Class and Object Diagrams.
Programmeren 1 6 september 2010 HOORCOLLEGE 2: INTERACTIE EN CONDITIES PROGRAMMEREN 1 6 SEPTEMBER 2009 Software Systems - Programming1 Programming.
Lecture by: Prof. Pooja Vaishnav.  Language Processor implementations are highly influenced by the kind of storage structure used for program variables.
Inheritance. Inheritance - Introduction Idea behind is to create new classes that are built on existing classes – you reuse the methods and fields and.
1 Chapter 7 Skip Lists and Hashing Part 2: Hashing.
Lecture 10 Page 1 CS 111 Summer 2013 File Systems Control Structures A file is a named collection of information Primary roles of file system: – To store.
ISBN Object-Oriented Programming Chapter Chapter
Chapter 15 A External Methods. © 2004 Pearson Addison-Wesley. All rights reserved 15 A-2 A Look At External Storage External storage –Exists beyond the.
Session 07 Module 13 - Collections. Collections / Session 7 / 2 of 32 Review  A delegate in C# is used to refer to a method in a safe manner.  To invoke.
Session 1 Module 1: Introduction to Data Integrity
Chapter 16 UML Class Diagrams 1CS6359 Fall 2012 John Cole.
Data Design and Implementation. Definitions Atomic or primitive type A data type whose elements are single, non-decomposable data items Composite type.
Chapter 11: Advanced Inheritance Concepts. Objectives Create and use abstract classes Use dynamic method binding Create arrays of subclass objects Use.
Access Specifier. Anything declared public can be accessed from anywhere. Anything declared private cannot be seen outside of its class. When a member.
Introduction to Collections. Collections Collections provide a way of organizing related data in a model Different types of collections have different.
JAVA: An Introduction to Problem Solving & Programming, 6 th Ed. By Walter Savitch ISBN © 2012 Pearson Education, Inc., Upper Saddle River,
1 Principles revisited.NET: Two libraries: System.Collections System.Collections.Generics Data Structures and Collections.
Java Methods A & AB Object-Oriented Programming and Data Structures Maria Litvin ● Gary Litvin Copyright © 2006 by Maria Litvin, Gary Litvin, and Skylight.
Sets and Maps Chapter 9. Chapter Objectives  To understand the Java Map and Set interfaces and how to use them  To learn about hash coding and its use.
Chapter 5 Record Storage and Primary File Organizations
Storage and File Organization
Sixth Lecture ArrayList Abstract Class and Interface
Chapter 6 Queue.
Data Structure Interview Question and Answers
Chapter 3: Using Methods, Classes, and Objects
Appendix D: Network Model
Array Array is a variable which holds multiple values (elements) of similar data types. All the values are having their own index with an array. Index.
Overview of Hadoop MapReduce MapReduce is a soft work framework for easily writing applications which process vast amounts of.
structures and their relationships." - Linus Torvalds
Object Oriented Analysis and Design
JavaScript: Arrays.
structures and their relationships." - Linus Torvalds
Presentation transcript:

Classes and objects Practice 2

Basic terms  Classifier is an element of the model, which specifies some general features for a set of objects. Features of the classifier can be behavioural, structural or connection.  Class is a classifier, which describes some the concept of the modeled area.

Basic terms  Interface is a special type of classifier that defines a way to interact with an instance of a class which implements this interface. The interface is typically involves operations, but sometimes it may include properties (attributes).  An instance of the class is an element of the model with descriptions, possibly incomplete, of the object, which has features of some definite class.

Task 1  The interface of accessing to the collection of the elements “Collection” summarizes the interface of working with lists “List”. An abstract class “BaseCollection” implements the interface “Collection”, an abstract class “BaseList” is a descendant of “BaseCollection” and implements an interface “List”, leaving the operation for storage of data to child classes.  Using the inheritance, add to the model a class “ArrayList” which implements the operations with lists by using an array.  Let the interface “List” contains an operation “get” for receiving the item of a list with a given position “k”. Specify in which classes this operation should be declared in order to model being consistent. Explain your answer.  Let the interface “Collection” contains the operation “add” for adding an element “obj”. Specify in which classes the behavior implementing the operation “add” may be present in namespace. Explain your answer.

Task 2  Class “Collections” contains public static operation “addAl”l with the returning value of a type “Boolean”. The first parameter of operation is called “coll” and has a type “Collection”, the second parameter is called “elements”, and has a type “Object” and the multiplicity greater than zero.  Add in a class “Collections” a static attribute “empty” of the type “collection”, intended only for reading.  Add in the class a line of conduct, which implements the operation “addAll”.

Task 3  The picture shows the pattern interfaces “Map” and “Entry”. “Map” allows to get the value of the type V by the key of the type K. Interface “Entry” is a pair of values.  Change the model so that the template “Entry” use the parameters of the template “Map”.  Define the interface “Map_StringInteger”, which specifies “String” as a type of a key and “Integer” as a type of the value in the template “Map”.  How many operations are there in the interface “Map_StringInteger”? Explain your answer.

Task 4  The interface of working with the associative array “Map” contatns in its space the interface of working with an element of an array “Entry”. The implementation of the interface “Map” includes several implementations of the interface “Entry”.  Add to the model the class “HashMap” which implements an associative array using a hash table, and the class “HashEntry” which implements the interface of working with an element of that array.  Let it be defined a private operation of increasing the size “resize” in the class “HashMap”. Under what conditions this operation will be available for the class “HashEntry”?  Using templates, choose that the type of a key and the type of a value of the interface of the associative array must match the types of a key and the type of a value in the interface of working with the elements of an array.

Task 5  The node of a tree “Node” can have multiple child nodes of the same class “Node”.  Using the model give an example of a binary tree, consisting of seven nodes.  Build a model of a tree in which each node has form two to five child nodes.  Develop a model of a tree, in which the nodes can be of two types: node “Oden” and node “Enod”.

Task 6  Hard disk “Disk” contains several folders “Folder” which can contain files “File” and folders. Works “Content” are stored on a disk in multiple files.  Using associations classes, build a model of the storage of works on a disk.  Complete the model, specify that the work can be either a picture “Picture” or some music “Music”, or film “Movie”.  Can the work be stored on one disk in different files? Explain your answer.

Task 7  Each instance of an abstract class “Controller” is connected under the association “Sensor” with several sensors “TrainSensor” of a train. In association “Controller” plays the role of a manager “controller”. Sensor of a train participates in the association as a sensor with a private visibility.  Using qualifiers, specify that each value of the index “Index” of a type “String” corresponds to no more than one sensor in the association “Sensor”.  Specify class “controller” so that this class receives signals of the approaching of a train “TrainSpotted” and distancing of the train “TrainLeft”, also it has the shared operation of executing commands “execute” with the parameter “cmd” of a data type “Command” and returns the value of a data type “Result”.  Define a class for a digital controller “DigitalController”, clarifying the class “controller”. In a class of a digital controller there is defined an operation “executeDigital”, which overrides the operation of executing commands of the controller and returns a numeric result “DigitalResult”.  Using instances of classes, give an example of a controller with two sensors.

Task 8  In the file system all data is stored in the chains of clusters, recorded in the file allocation table FAT. The table contains clusters “Cluster”, the cluster is the index of the next cluster in the chain. The cluster of the directory “Folder” contains an ordered set “lists” of records “Entry” for the files and directories. Each of their records indicates the size “size”, name “name”, attributes “attrs” and the initial cluster “Cluster”.  Specify a model so that a cluster may not be the next one in the file allocation table.  Using constraints, define a data type “Byte” with a range of values from 0 to 255.  Add a new type of cluster – the cluster “Data”, containing the data of files. Operation “getData” allows you to retrieve data of this class in the form of an array with elements of type Byte.  Specify that except “Folder” and “Data” the clusters may be only spoiled “Bad” and reserve “Reserved”.  Give an example of the file allocation table with five clusters with a single directory “folder” and two files “file1” and “file2”. “File1” is located in the cluster with the number 3, “file2” - in clusters 2 and 4. The table is placed in the first cluster, it is reserved.