Abdelnasser Ouda page 1 Spring 2023XXXXXXXXXXUNIVERSITY OF NOTH TEXAS XXXXXXXXXXCOLLEGE OF ENGINEERING DEPARTMENT OF COMPUTER SCIENCE & ENGINEERINGCSCE 4110 SPRING 2023–...

complete programming assignment










Abdelnasser Ouda page 1 Spring 2023 UNIVERSITY OF NOTH TEXAS COLLEGE OF ENGINEERING DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING CSCE 4110 SPRING 2023– ALGORITHMS Assignment 2 - Dictionaries Due Date: Monday March 20th, 2023, at 5:00 PM This is a teamwork assignment. You can work in groups of up to 3 students. If you are working within a team, please make sure that the EUID of ALL team members are in the final submission file name. 1 Goals At the end of this assignment, you should be able to: • Write Java code for a simple database manager that will store a set of objects species in an ordered dictionary (an implemented Birds project, as one of objects species, would be given as example). • Understand how to implement dictionary ADT using a binary search tree. • Use JavaFX and Scene Builder to build graphical user interface GUI application. 2 Description and Requirements The most common objective of software applications is to store and retrieve data, in which the efficiency of organizing a collection of this data is a paramount. In this assignment, you will work on a simple interface for such a collection, called a dictionary, your dictionary will house a collection of object species data records. You will consider the dictionary ADT that provides operations for storing records, finding records, and removing records from the collection. Dictionaries depend on the concepts of a search key and comparable objects. To implement the dictionary's search function, we will require that keys be totally ordered. Ordering fields that are naturally multi- dimensional, such as a point in two or three dimensions, present special opportunities if we wish to take advantage of their multidimensional nature. Each record in your collection will be stored in the form of (DataKey, about, sound, image), where ‘about’ is string holding the information we collect about the object, ‘sound’ is the audio filename of the object’s sound, ‘image’ is the filename of the object’s image, and ‘DataKey’ is a pair (objectName, objectSize), where the objectName (e.g., birdName) is a string representing a unique identification of the object (bird), and the objectSize (e.g., birdSize) is an integer value as follows: o objectSize = 1, if object’s size is small. o objectSize = 2, if object’s size is medium. o objectSize = 3, if object’s size is large. Please note that, in the rest of this Assignment2 specification, we will address the bird object as an example. However, in your Assignment2 solution you MUST address different object species/name. When comparing two DataKey k1 = (birdName1, birdSize1) and k2 = (birdName2, birdSize2), we use the following rules: ➢ k1 = k2, if birdSize1 = birdSize2 and birdName1= birdName2 ➢ k1< k2,="" if="" birdsize1="">< birdsize2 or if birdsize1 = birdsize2, and birdname1 precedes birdname1. csce4110 algorithms 2 - dictionaries abdelnasser ouda page 2 spring 2023 consider, for example, a database storing the following birds’ records: o record1 = ((“rock pigeon”, 2), “common throughout the continental united states, southern canada, mexico, and urban areas throughout the world.”, “rock pigeon.mp3”, “rock pigeon.jpg”) o record2 = ((“ringed kingfisher”, 2), “commonly found along the lower rio grande valley in south-eastern most texas in the united states through central america to tierra del fuego in south america.”, “ringed kingfisher.mp3”, “ringed kingfisher.jpg”) o record3 = ((“northern cardinal”, 3), “this large crested finch has a vivid red body. the black mask and chin contrast with a heavy red bill.”, “northern cardinal.mp3”, “northern cardinal.jpg”) in the above dataset, we have recod1 and record2 are smaller than record3 because their birdsize are smaller than the birdsize of record3. and record2 is smaller than record1 because the birdname of record2 alphabetically comes before the birdname of record1, note that, both records have the same birdsize. your application will provide a gui-based interface that will allow users to interact with the database through number of menu items, text fields and buttons. javafx and scene builder will be your programming language and the tools to build your application. please use intellij ide to develop your application. figure 1, shows a sample run of the required application, the following describe how would your application behave. 2.1 the main menu the application starts showing its initial state, where a blank screen with unt logo in the background will be displayed in addition to one main menu at the top. the main menu of the application will include a ‘file’ menu that has two menu items ‘fill dictionary’ and ‘close’. when a user chooses file → fill dictionary option, the application will read the birds information from the given text file and populate the dictionary (the bird database) using the insert method. when the dictionary is filled the first bird in the database will be displayed. figure1: (a) shows the initial stage of the application. (b) shows the application screen when the database is filled. csce4110 algorithms 2 - dictionaries abdelnasser ouda page 3 spring 2023 2.2 search bird the application should provide the feature for searching the database for a specific bird by its name and size. the user need to enter the bird full name in bird name textfield and choose the bird’s size from the combobox and then click find. the application will display the name, title, and the image of the bird if it exists or show an appropriate error message on the screen. 2.3 play/stop sound the application should be able to play the sound of the correct bird displayed on the screen. when the user clicks play button the sound begins playing, until the audio file ends or the user click stop button. this application supports mp3 audio files only. 2.4 delete bird when the user clicks the ‘delete’ button, the application should remove the current displayed bird from the database using the dictionary remove() method. after the record is deleted the available next or previous record will be displayed, if the deleted record was the last one in the database, the application will be reset to its initial state. that is a blank screen with unt logo in the background in addition to the main menu at the top, the user can close the application or re-start again. 2.5 next bird when the user clicks the ‘next’ button, the application should display the bird information in the database that follows the current bird using the dictionary method successor (). if such a record does not exist because there is no record in the database with key larger than the current one then an appropriate message is displayed. 2.6 previous bird when the user clicks the ‘previous’ button, the application should display the bird information in the database that precedes the current bird using the dictionary method predecessor (). if such a record does not exist because there is no record in the database with key smaller than the current one then an appropriate message is displayed. 2.7 first bird when the user clicks the ‘first’ button, the application should display the bird information with smallest key in the database using the dictionary method smallest (). 2.8 last bird when the user clicks the ‘last’ button, the application should display the bird information with largest key in the database using the dictionary method largest (). 2.9 close application the application should exit, when the user chooses file → close. 3 objects implementations to make your life easier, a start-up application kit is given. it includes a template gui interface, birds’ images, audio files, the java exceptions classes, the orderdictionaryadt interface, and the units testing code. if you did not do it already, download the file birds.zip and import it into your intellij ide. you are required to csce4110 algorithms 2 - dictionaries abdelnasser ouda page 4 spring 2023 implement the following java classes: datakey, birdrecord, ordereddictionary, and to modify the birdcontroller along with its birds.fxml. feel free to implement more classes if you need to, for example you may need to implement a node class for your binary tree in addition to the form that will display the error messages. 3.1 datakey each record in your database will be stored in the form of (datakey, about, sound, image), and the datakey is a pair (birdname, birdsize) as described above. for this class you must implement the following public methods, however, you can implement any other methods that you want to in this class, but they must be declared as private methods. 1. the constructor(s) of the class. 2. public string getbirdname(), the method that returns the birdname of the datakey. 3. public int getbirdsize(), the method that returns the type of the datakey. 4. public int compareto(datakey k), the method that returns 0 if this datakey is equal to k, returns -1 if this datakey is smaller than k, and it returns 1 otherwise. 3.2 birdrecord this class represents a bird record in the database. each record consists of the followings: a ‘key’ of type datakey, ‘about’ of type string to hold the bird description, ‘sound’ of type string to hold the audio file name, ‘image’ of type string to hold the bird image name. for this class, you must implement the following public methods, however, you can implement any other methods that you want to in this class, but they must be declared as private methods. 1. the constructor(s) of the class. 2. public datakey getdatakey(), the method that returns the key of the record. 3. public string getabout(), the method that returns the bird description in the record. 4. public string getsound(), the method that returns the bird audio file name. 5. public string getimage(), the method that returns the bird image file name. 3.3 ordereddictionary you will build your database using a dictionary data structure. in this application, a binary tree will be used to implement your dictionary and not need to be balanced tree. the ordereddictionary class should be a direct implementation to the given ordereddictionaryadt interface. you must use a birdrecord object to store the data contained in each node of the tree. in your binary search tree, only the internal nodes will store information. the leaves will be java objects storing null objects. the dictionary key for an internal node will be the datakey object from the birdrecord stored in that node. again, you might want to implement a class node to represent the nodes of the binary search tree. each node will store a birdrecord, and references to its left child, right child, and parent. when comparing two node keys you need to use method compareto() from class datakey. keep in mid that you must implement all the public methods declared in the given ordereddictionaryadt interface, and to use the given dictionary exception class to handle the exceptional cases as it is mentioned in top of each method. note that, you need to catch these exceptions in the birdscontroller class and display their messages on the screen. you will need create another fxml file. 3.4 birdscontroller birdscontroller is the class that interacts with the birds.fxml file to show the main application interface and to control the behaviour of the entire application. in this class you need to implement at least the following public methods: first(), last(), next(), previous(), delete(), find(), play(), and stop() to handle the application csce4110 algorithms 2 - dictionaries abdelnasser ouda page 5 spring 2023 buttons clicks. in addition to the method loaddictionary() to be called when the user choose file → fill dictionary. this method should be able to read the birds information from the given text file that has the following format. each bird record has three lines of data, the first line contains a number that represent the bird size, the second line contains a string birdsize2="" or="" if="" birdsize1="birdSize2," and="" birdname1="" precedes="" birdname1.="" csce4110="" algorithms="" 2="" -="" dictionaries="" abdelnasser="" ouda="" page="" 2="" spring="" 2023="" consider,="" for="" example,="" a="" database="" storing="" the="" following="" birds’="" records:="" o="" record1="((“Rock" pigeon”,="" 2),="" “common="" throughout="" the="" continental="" united="" states,="" southern="" canada,="" mexico,="" and="" urban="" areas="" throughout="" the="" world.”,="" “rock="" pigeon.mp3”,="" “rock="" pigeon.jpg”)="" o="" record2="((“Ringed" kingfisher”,="" 2),="" “commonly="" found="" along="" the="" lower="" rio="" grande="" valley="" in="" south-eastern="" most="" texas="" in="" the="" united="" states="" through="" central="" america="" to="" tierra="" del="" fuego="" in="" south="" america.”,="" “ringed="" kingfisher.mp3”,="" “ringed="" kingfisher.jpg”)="" o="" record3="((“Northern" cardinal”,="" 3),="" “this="" large="" crested="" finch="" has="" a="" vivid="" red="" body.="" the="" black="" mask="" and="" chin="" contrast="" with="" a="" heavy="" red="" bill.”,="" “northern="" cardinal.mp3”,="" “northern="" cardinal.jpg”)="" in="" the="" above="" dataset,="" we="" have="" recod1="" and="" record2="" are="" smaller="" than="" record3="" because="" their="" birdsize="" are="" smaller="" than="" the="" birdsize="" of="" record3.="" and="" record2="" is="" smaller="" than="" record1="" because="" the="" birdname="" of="" record2="" alphabetically="" comes="" before="" the="" birdname="" of="" record1,="" note="" that,="" both="" records="" have="" the="" same="" birdsize.="" your="" application="" will="" provide="" a="" gui-based="" interface="" that="" will="" allow="" users="" to="" interact="" with="" the="" database="" through="" number="" of="" menu="" items,="" text="" fields="" and="" buttons.="" javafx="" and="" scene="" builder="" will="" be="" your="" programming="" language="" and="" the="" tools="" to="" build="" your="" application.="" please="" use="" intellij="" ide="" to="" develop="" your="" application.="" figure="" 1,="" shows="" a="" sample="" run="" of="" the="" required="" application,="" the="" following="" describe="" how="" would="" your="" application="" behave.="" 2.1="" the="" main="" menu="" the="" application="" starts="" showing="" its="" initial="" state,="" where="" a="" blank="" screen="" with="" unt="" logo="" in="" the="" background="" will="" be="" displayed="" in="" addition="" to="" one="" main="" menu="" at="" the="" top.="" the="" main="" menu="" of="" the="" application="" will="" include="" a="" ‘file’="" menu="" that="" has="" two="" menu="" items="" ‘fill="" dictionary’="" and="" ‘close’.="" when="" a="" user="" chooses="" file="" →="" fill="" dictionary="" option,="" the="" application="" will="" read="" the="" birds="" information="" from="" the="" given="" text="" file="" and="" populate="" the="" dictionary="" (the="" bird="" database)="" using="" the="" insert="" method.="" when="" the="" dictionary="" is="" filled="" the="" first="" bird="" in="" the="" database="" will="" be="" displayed.="" figure1:="" (a)="" shows="" the="" initial="" stage="" of="" the="" application.="" (b)="" shows="" the="" application="" screen="" when="" the="" database="" is="" filled.="" csce4110="" algorithms="" 2="" -="" dictionaries="" abdelnasser="" ouda="" page="" 3="" spring="" 2023="" 2.2="" search="" bird="" the="" application="" should="" provide="" the="" feature="" for="" searching="" the="" database="" for="" a="" specific="" bird="" by="" its="" name="" and="" size.="" the="" user="" need="" to="" enter="" the="" bird="" full="" name="" in="" bird="" name="" textfield="" and="" choose="" the="" bird’s="" size="" from="" the="" combobox="" and="" then="" click="" find.="" the="" application="" will="" display="" the="" name,="" title,="" and="" the="" image="" of="" the="" bird="" if="" it="" exists="" or="" show="" an="" appropriate="" error="" message="" on="" the="" screen.="" 2.3="" play/stop="" sound="" the="" application="" should="" be="" able="" to="" play="" the="" sound="" of="" the="" correct="" bird="" displayed="" on="" the="" screen.="" when="" the="" user="" clicks="" play="" button="" the="" sound="" begins="" playing,="" until="" the="" audio="" file="" ends="" or="" the="" user="" click="" stop="" button.="" this="" application="" supports="" mp3="" audio="" files="" only.="" 2.4="" delete="" bird="" when="" the="" user="" clicks="" the="" ‘delete’="" button,="" the="" application="" should="" remove="" the="" current="" displayed="" bird="" from="" the="" database="" using="" the="" dictionary="" remove()="" method.="" after="" the="" record="" is="" deleted="" the="" available="" next="" or="" previous="" record="" will="" be="" displayed,="" if="" the="" deleted="" record="" was="" the="" last="" one="" in="" the="" database,="" the="" application="" will="" be="" reset="" to="" its="" initial="" state.="" that="" is="" a="" blank="" screen="" with="" unt="" logo="" in="" the="" background="" in="" addition="" to="" the="" main="" menu="" at="" the="" top,="" the="" user="" can="" close="" the="" application="" or="" re-start="" again.="" 2.5="" next="" bird="" when="" the="" user="" clicks="" the="" ‘next’="" button,="" the="" application="" should="" display="" the="" bird="" information="" in="" the="" database="" that="" follows="" the="" current="" bird="" using="" the="" dictionary="" method="" successor="" ().="" if="" such="" a="" record="" does="" not="" exist="" because="" there="" is="" no="" record="" in="" the="" database="" with="" key="" larger="" than="" the="" current="" one="" then="" an="" appropriate="" message="" is="" displayed.="" 2.6="" previous="" bird="" when="" the="" user="" clicks="" the="" ‘previous’="" button,="" the="" application="" should="" display="" the="" bird="" information="" in="" the="" database="" that="" precedes="" the="" current="" bird="" using="" the="" dictionary="" method="" predecessor="" ().="" if="" such="" a="" record="" does="" not="" exist="" because="" there="" is="" no="" record="" in="" the="" database="" with="" key="" smaller="" than="" the="" current="" one="" then="" an="" appropriate="" message="" is="" displayed.="" 2.7="" first="" bird="" when="" the="" user="" clicks="" the="" ‘first’="" button,="" the="" application="" should="" display="" the="" bird="" information="" with="" smallest="" key="" in="" the="" database="" using="" the="" dictionary="" method="" smallest="" ().="" 2.8="" last="" bird="" when="" the="" user="" clicks="" the="" ‘last’="" button,="" the="" application="" should="" display="" the="" bird="" information="" with="" largest="" key="" in="" the="" database="" using="" the="" dictionary="" method="" largest="" ().="" 2.9="" close="" application="" the="" application="" should="" exit,="" when="" the="" user="" chooses="" file="" →="" close.="" 3="" objects="" implementations="" to="" make="" your="" life="" easier,="" a="" start-up="" application="" kit="" is="" given.="" it="" includes="" a="" template="" gui="" interface,="" birds’="" images,="" audio="" files,="" the="" java="" exceptions="" classes,="" the="" orderdictionaryadt="" interface,="" and="" the="" units="" testing="" code.="" if="" you="" did="" not="" do="" it="" already,="" download="" the="" file="" birds.zip="" and="" import="" it="" into="" your="" intellij="" ide.="" you="" are="" required="" to="" csce4110="" algorithms="" 2="" -="" dictionaries="" abdelnasser="" ouda="" page="" 4="" spring="" 2023="" implement="" the="" following="" java="" classes:="" datakey,="" birdrecord,="" ordereddictionary,="" and="" to="" modify="" the="" birdcontroller="" along="" with="" its="" birds.fxml.="" feel="" free="" to="" implement="" more="" classes="" if="" you="" need="" to,="" for="" example="" you="" may="" need="" to="" implement="" a="" node="" class="" for="" your="" binary="" tree="" in="" addition="" to="" the="" form="" that="" will="" display="" the="" error="" messages.="" 3.1="" datakey="" each="" record="" in="" your="" database="" will="" be="" stored="" in="" the="" form="" of="" (datakey,="" about,="" sound,="" image),="" and="" the="" datakey="" is="" a="" pair="" (birdname,="" birdsize)="" as="" described="" above.="" for="" this="" class="" you="" must="" implement="" the="" following="" public="" methods,="" however,="" you="" can="" implement="" any="" other="" methods="" that="" you="" want="" to="" in="" this="" class,="" but="" they="" must="" be="" declared="" as="" private="" methods.="" 1.="" the="" constructor(s)="" of="" the="" class.="" 2.="" public="" string="" getbirdname(),="" the="" method="" that="" returns="" the="" birdname="" of="" the="" datakey.="" 3.="" public="" int="" getbirdsize(),="" the="" method="" that="" returns="" the="" type="" of="" the="" datakey.="" 4.="" public="" int="" compareto(datakey="" k),="" the="" method="" that="" returns="" 0="" if="" this="" datakey="" is="" equal="" to="" k,="" returns="" -1="" if="" this="" datakey="" is="" smaller="" than="" k,="" and="" it="" returns="" 1="" otherwise.="" 3.2="" birdrecord="" this="" class="" represents="" a="" bird="" record="" in="" the="" database.="" each="" record="" consists="" of="" the="" followings:="" a="" ‘key’="" of="" type="" datakey,="" ‘about’="" of="" type="" string="" to="" hold="" the="" bird="" description,="" ‘sound’="" of="" type="" string="" to="" hold="" the="" audio="" file="" name,="" ‘image’="" of="" type="" string="" to="" hold="" the="" bird="" image="" name.="" for="" this="" class,="" you="" must="" implement="" the="" following="" public="" methods,="" however,="" you="" can="" implement="" any="" other="" methods="" that="" you="" want="" to="" in="" this="" class,="" but="" they="" must="" be="" declared="" as="" private="" methods.="" 1.="" the="" constructor(s)="" of="" the="" class.="" 2.="" public="" datakey="" getdatakey(),="" the="" method="" that="" returns="" the="" key="" of="" the="" record.="" 3.="" public="" string="" getabout(),="" the="" method="" that="" returns="" the="" bird="" description="" in="" the="" record.="" 4.="" public="" string="" getsound(),="" the="" method="" that="" returns="" the="" bird="" audio="" file="" name.="" 5.="" public="" string="" getimage(),="" the="" method="" that="" returns="" the="" bird="" image="" file="" name.="" 3.3="" ordereddictionary="" you="" will="" build="" your="" database="" using="" a="" dictionary="" data="" structure.="" in="" this="" application,="" a="" binary="" tree="" will="" be="" used="" to="" implement="" your="" dictionary="" and="" not="" need="" to="" be="" balanced="" tree.="" the="" ordereddictionary="" class="" should="" be="" a="" direct="" implementation="" to="" the="" given="" ordereddictionaryadt="" interface.="" you="" must="" use="" a="" birdrecord="" object="" to="" store="" the="" data="" contained="" in="" each="" node="" of="" the="" tree.="" in="" your="" binary="" search="" tree,="" only="" the="" internal="" nodes="" will="" store="" information.="" the="" leaves="" will="" be="" java="" objects="" storing="" null="" objects.="" the="" dictionary="" key="" for="" an="" internal="" node="" will="" be="" the="" datakey="" object="" from="" the="" birdrecord="" stored="" in="" that="" node.="" again,="" you="" might="" want="" to="" implement="" a="" class="" node="" to="" represent="" the="" nodes="" of="" the="" binary="" search="" tree.="" each="" node="" will="" store="" a="" birdrecord,="" and="" references="" to="" its="" left="" child,="" right="" child,="" and="" parent.="" when="" comparing="" two="" node="" keys="" you="" need="" to="" use="" method="" compareto()="" from="" class="" datakey.="" keep="" in="" mid="" that="" you="" must="" implement="" all="" the="" public="" methods="" declared="" in="" the="" given="" ordereddictionaryadt="" interface,="" and="" to="" use="" the="" given="" dictionary="" exception="" class="" to="" handle="" the="" exceptional="" cases="" as="" it="" is="" mentioned="" in="" top="" of="" each="" method.="" note="" that,="" you="" need="" to="" catch="" these="" exceptions="" in="" the="" birdscontroller="" class="" and="" display="" their="" messages="" on="" the="" screen.="" you="" will="" need="" create="" another="" fxml="" file.="" 3.4="" birdscontroller="" birdscontroller="" is="" the="" class="" that="" interacts="" with="" the="" birds.fxml="" file="" to="" show="" the="" main="" application="" interface="" and="" to="" control="" the="" behaviour="" of="" the="" entire="" application.="" in="" this="" class="" you="" need="" to="" implement="" at="" least="" the="" following="" public="" methods:="" first(),="" last(),="" next(),="" previous(),="" delete(),="" find(),="" play(),="" and="" stop()="" to="" handle="" the="" application="" csce4110="" algorithms="" 2="" -="" dictionaries="" abdelnasser="" ouda="" page="" 5="" spring="" 2023="" buttons="" clicks.="" in="" addition="" to="" the="" method="" loaddictionary()="" to="" be="" called="" when="" the="" user="" choose="" file="" →="" fill="" dictionary.="" this="" method="" should="" be="" able="" to="" read="" the="" birds="" information="" from="" the="" given="" text="" file="" that="" has="" the="" following="" format.="" each="" bird="" record="" has="" three="" lines="" of="" data,="" the="" first="" line="" contains="" a="" number="" that="" represent="" the="" bird="" size,="" the="" second="" line="" contains="" a="">
Mar 21, 2023
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here