• Home
  • Blog
  • reverse file this project is intended to reverse the contents of a file using a generic stack data structure

reverse file this project is intended to reverse the contents of a file using a generic stack data structure

0 comments

This project is intended to reverse the contents of a file using a generic stack data structure. You will create a generic Reverser class that will be used for two different data types: string and float. An object of the reverser class declared as a string reverser will be used to create a reverse poem. Another object of the reverser class, this one declared as a float reverser, will be used to get spell potency values for a maji game.
For this project, you will need the generic classes from this module topic:
A Generic Stack
(https://www.fgamedia.org/faculty/loceff/cs_courses…)
You will not modify the Stack or Node classes. Instead, you need to create a new generic Reverser class.
Requirements for the generic Reverser class:

This class must be named Reverser and must be a generic class.
Instance members: private object of the Stack class (use the generic data type).
Constructor method: instantiate the object of the Stack class with the generic type
FileToStack method:

This must have a parameter list that includes the input filename.
Read the file and fill the stack using the push method.

StackToFile method:

This must have a parameter list that includes the output filename.
Write the contents of the stack to a different file from the return values of the pop method. The output file should contain the same lines as the input file, but in reverse order.

Handle all file-related exceptions outlined in the modules

For testing, let’s look at why we need the Reverser class.
Reverse Poem
We need a reverser class to assist poets who are trying to create a reverse poem, or palindrome poem, which is a poem that can be read forwards one way and have a meaning, but also be read backwards and have another different meaning.
A poet needs to input a file that contains a forward poem and get the reverse version of the poem written to another file. If you would like to use the above poem for testing, you can download the forward version of this poem here (click to go to the download page): reversePoem.txt Note: each line of the file represents a single string.
Maji Game
We also need the reverser class to assist with a larger game that includes characters who battle using magical spells. Because each of the spells has a potency value, the spell with the highest potency wins the battle. In one phase of the game, players must stack their spells for a speed battle round. The last spell in the stack is played first. You will use the reverser class to load a file that contains one player’s stack of spell potency values into the stack, then print the stack in reverse order to simulate the order each spell potency will be used in the speed round. You can create your own input file, or use this one (click to go to the download page): reverseSpells.txt Note: each line of the file represents a different spell potency value.
Requirements for the main class:
Reverse Poem

Create an object of the reverser class for a poem. This will be a String Reverser object.
Call the FileToStack method and pass the filename for the reverseme.txt file.
Call the StackToFile method and pass a different filename. Confirm that the output file contains all of the lines from the poem in the input file, but in reverse order

Maji Game

Create an object of the Reverser class for a stack of floats for the magi spell potency values. This will be an int Reverser object.
Call the FileToStack method and pass a new filename for the list of magi spell potency values for a single player.
Call the StackToFile method and pass a different filename for the maji’s output file. Confirm that the output file contains all of the values from the input file, but in reverse order.

Note: A console application is all you need for this project. A User Interface (UI) is not required, but if you prefer to create a Swing project or JavaFX project, you are welcome to do so.
 
Do you need a similar assignment done for you from scratch? We have qualified writers to help you. We assure you an A+ quality paper that is free from plagiarism. Order now for an Amazing Discount! Use Discount Code “Newclient” for a 15% Discount!NB: We do not resell papers. Upon ordering, we do an original paper exclusively for you.

The post reverse file this project is intended to reverse the contents of a file using a generic stack data structure appeared first on Custom Nursing Help.

About the Author

Follow me


{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}