In this IT programming database assignment help is based on data structure and help to learn about concepts like looping, iterations, selection, data flow
This assignment has been made in order to understand the concepts learnt during lectures and apply them through implementation. It provides the platform to enhance learner programming and testing skills. It helps you to understand the concepts of primitive data types, loops, structures, arrays and so on. The java programming language is used to implement this solution and eclipse editor is used.
Part A – Code Comprehension
1 Draw a UML diagram for each class
2 To draw a UML for shapes list class
3 To add proper comments in shapelist.java file
The comments are appropriately added in the shape list.java file.
4 Purpose of calling has Next Line () method
Purpose of the has Next Line () method in ShapesList.java class
The has Next Line () is a method of scanner class in java. This method is used to check there is another line for input in scanner or not. If another line is found as input then this method returns true else this method returns false. In Shapes List.java class a text file named Shapes File.txt is an input file from which the shapes input are taken. [Also Read: – Desktop Application Dot Net Assignment Help] The has Next Line () method returns true if in the input file there is another line else it returns false. If this method is returning true that means there is another line left in the file to read else the file has been completed input.
The read From File () is a method of Shapes List.java. This is declared in this class and the return type of this method is void and this method can be accessed publicly. This method doesn’t have any parameter. Using this method the following task will be performed:
- New object of the File will be created.
- This object of the File will input the input File.
- A new object of the Scanner class will be created to read the input line. Using this scanner object hasNextLine() method will be called where if it returns true it means it has more line to read else it will return false that means there is no rest input.
- The input file will be checked and on the basis of the input file type the shape will be created. If the file is found of square type then all the properties of the square such as the name of the shape, color of the shape and also the coordinates of the shape will be set.
- This input file properties setting is done using switch case. If the input type is found as rectangle all the properties of the rectangle will be set.
5 To explain the entire code of bubble sort
A bubble sort is a sorting algorithm which is used to sort the data in an appropriate order. This sorting is done by swapping those swipes the items till they don’t appear in a correct order. This algorithm shorts the largest number first and then the smaller item. This is due to that the smaller item took more time to fit at the correct order then a largest item. [Also Read: – Staff Payroll System Database Assignment Help]
In Shapes List.java class Bubble Sort method is used to sort the shapes. This sorting of shapes is done on the basis of the area which a shape covered. To do this task there is a method in Shapes List.java named as bubble Sort () which has return type void and can be accessed publicly. This method in the Shapes List.java class performs the following task:
- This creates a new variable of type Shapes.
- Now checks the size of the list and after this checking this get the value of the area of the on a position and compares this value with another position. It swipes the value with the larger one using the third variable which was declared.
- Finally if all the items are sorted it stops the sorting.
The sort algorithm which is used in Shapes List.java class to sort all the shapes on the basis of their area is the bubble sorting algorithm. This algorithm uses swipe method to sort the numbers.
Bubble sort algorithm is bases on the passes and it makes multiple passes through a list. This compares adjacent items and swipes those that are not in order. Every swipe places the next value and compares with the current value and places the largest value at its right place.
Example of the bubble sort algorithm:
Assume a list is 15 10 5 20
Read more about Online Assignment Help
This will take the first item of the list which is 15 and will compare this with the rest items. Such as firstly it will compare with 10 and 10<15 so it will swipe the item. Now the list will be
10 15 5 20
Now it will again compare the item with the next item which is 5. 5<15 so it will swipe and the new list will be
10 5 15 20
Now it will again compare this with the next item which is 20. 20>15 so it will now swipe and the final string will be
10 5 15 20
Now this will select the next variable which is 10 and will compare this with another variable such as the next variable is 5. 5<10 so it will swipe this and the list will be
5 10 15 20
Now it will apply the same process with another items and the final string after performing all the sorting step will be
5 10 15 20
In this sorting algorithm we need to use two loops so that we can compare the items. The first loop is to get the size so that the repetition can be fixed and another loop is to get the data so that comparison can be done. [Also Read: – Phone Book Management Web Programming Assignment]
6 To describe another sorting algorithm
Insertion sort algorithm can be used at the place of bubble sort. Both have the sorting stability.
To sort the data according to the insertion sort there is need to do the following things:
- First of all assume a store list of item 1.
- Compare the next item with this if the item is greater than another then pass the item else compare the next item with these two items.
- If the next compared item is small placing its value else compare the next.
For example let’s have a list 52 26 36 20 7
Step 1 First of all assume there is stored list with the item 52
Step 2 Compare this item with the next item which is 26. 26<52 so it will swipe the element.
Now the list will be 26 52 36 20 7
Step 3 now compare the next item with these two items which is 36. Now 36 <52 so perform swipe and 26<36 so the final list will be
26 36 52 20 7
Step 4 now compare the next item which is 20 with all the rest items.
52>20 so perform swipe. 36>20 so perform swipe. 26>20 so perform swipe.
Final list will be
20 26 36 52 7
Now compare the next item which is 7 with the rest items.
52>7 so perform swipe.
36>7 so perform swipe.
26>7 so perform swipe.
20>7 so perform swipe.
Final list will be
7 20 26 36 52
The final list is the sorted list.
7 To brief the usage of return value in get area method
The get Area () method of Rectangel.java class is created in Rectangle class to calculate the area of the rectangle. Another method named calc Area () is called in this method which returns the product of length and breadth of the rectangle which is area of the rectangle. Using scanner class the length and breadth are taken as input from the user to perform calculation and to get all the properties of the shape. Now to calculate the area of the rectangle, this get Area () method of Rectangle.java class is used.
8 Examine the following code
Output file of the given program will be located where the program will be stored. It will be saved in the same folder where the program is saved. Buffered Writer () is used to write the file which will be received as output such as after calculation the output file will have name of the shape, color of the shape, the coordination and the area of the shape to write these all values Buffered Writer () is used. This class is a character streamed class which saves and writes data in character. So using the Buffered Writer () the data output file will be write by character and this class is used to write the data. [Also Read: – Office Solution Development Assignment Help]
9 To define the usage of ‘\r\n’ in to String () method
\r is the carriage return and the \n is for the new line. In the method to String () of ShapesList.java these both \r\n used. In to String () method of Shapes List.java class there is the value or the result storage in a variable so the \r\n enters the new value in the new line and at the starting of the line. This will help to keep the data difference else the data will be merged with each other. Simply the carriage return keeps the cursor in the starting of the line and the new line sends the data in the new line.
10 To elaborate try catch clause
In Shapes List.java class while reading data from the input file try and catch block is added because when the scanner class is used it reads data from the input file. This class is used to read the data but there may be a case of exception such as there the file may be not available so there is the need to use the try and catch block to handle the exception.
When we remove the input file and the try and catch block from the class and execute it firstly it shows the warning that the developer has not added try and catch block to handle the exception and after adding this block and removing the input file there will be an error named as class not found exception which will be handled by the catch class and this will print the error and will not show any output. [Also Read:- Develop Web Application for Hotel Rooms Reservation System]
Part C- Extending classes through inheritance
1 Explain the implementation of healer.java and fight.java classes
In the document we will discuss about how we can create a class Fighter and Healer by using class Character. Thought behind how to create fighter and healer classes-
As we know very well that we will have to implement both Character classes by using Character class with having all previous attributes, so we can create a class Fighter class extending Character class so we can have all the existing attributes of the Character class and by adding new special attributes to child class Fighter class, similarly another class Healer class can be created.
Read more about Assignment Help Australia
We will provide our new method in the both classes Fighter and Healer to have special powers with in their attributes.
2 Can insertion be done in game object?
At the time of insertion of these special type of characters in the game array, we can use two more menus to use them as, “Insert a fighter” and “Insert a healer” in the menu system. Or we have one another option to create them, we just can ask at the time of new character insertion that which type of character would user wants to insert in the array of character.
There is a simple relationship between fighter / healer and character class as both new classes are the sub classes of the super class Character, so both new classes can have ability to be a basic character as well as a super power character. We just need to create get and set method for the new attributes like healing power and killing power. These powers can be utilized for any object of the fighter and healer class but can’t be used by the super class character as this is the base class of both new character classes. We just need to take care of some Java inheritance rules and new classes can be easily implemented. [Also Read:- Australian Seeds Web Programming Assignment Help]
At the end of the completion of the task the learner will get acquainted with the programming concepts such as looping, iterations, selection, data flow and so on.
Docs.oracle.com,. (2016). The for Statement (The Java™ Tutorials > Learning the Java Language > Language Basics). Retrieved 30 January 2016, from https://docs.oracle.com/javase/tutorial/java/nutsandbolts/for.html
www.tutorialspoint.com,. (2016). Java – Characters. Retrieved 30 January 2016, from http://www.tutorialspoint.com/java/java_characters.htm
Top Grade Assignment Help provide technical assignment writing service based on case study requirements in affordable prices and we are providing most flexible online assignment writing help, so book your Assignment with us, order now