Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have this Data Structures project that I'm struggle with and need help. Some specification and a MUST..Do not use Java-provided classes (List, Collections, Comparator)

I have this Data Structures project that I'm struggle with and need help. Some specification and a MUST..Do not use Java-provided classes (List, Collections, Comparator) or methods (Collections.sort)..You have to implement the classes like State,Stack, Queue and Priority Queue classes...Please use these specific details Here is the project: COP3538 Project 2 Stacks and Priority Queues Liu University of North Florida 1 Due Date: Friday, 02/22/2019 11:59 PM Turn in: Submit the zipped Eclipse program including at least Project2.java, Stack.java, Priority.java, State.java and States2.csv. The zip file should be named _Project2.zip (for example, Liu_Project2.zip). The program should be well documented in the format of doc comments in Java. Detailed formats are found at http://www.oracle.com/technetwork/articles/java/index-137868.html. Requirements: 1. Reuse your State class from Project 1 (correct it if necessary) 2. Create a class named Stack that will implement a stack of state objects using an array. Support the following methods. a. Constructor that creates the stack array based on a size provided. b. A push method to push a state on the stack c. A pop method to pop a state off the stack and return it. d. A printStack method to print the stack, see the example. e. An isEmpty method that returns true if the stack is empty, false otherwise f. An isFull method that returns true if the stack is full, false otherwise 3. Create a class named Priority that implements a priority queue of state objects using an array, based on population, highest population is the highest priority. Support the following methods: a. Constructor that creates the stack array based on a size provided. b. An insert method to insert a state into the queue. c. A remove method to remove a state from the front of the queue and return it. d. A printQueue method to print the queue in priority order, see the example. e. An isEmpty method that returns true if the queue is empty, false otherwise f. An isFull method that returns true if the queue is full, false otherwise 4. Create a class named Project2 that will: a. Read the csv file (States2.csv) of states and create a single stack of state objects containing states from regions South, West, and Midwest that data (discard any states not in those regions, do not modify the input file.). b. Print the stack starting with the top of the stack. c. Create three priority queues, one for each region. d. Pop states off the stack one at a time and insert them into the appropriate priority queue until the stack is empty. e. Print all three priority queues in this order: South, West, then Midwest. f. Remove items from the South priority queue, one at a time, and push them on the stack. g. Remove items from the West priority queue, one at a time, and push them on the stack. h. Remove items from the Midwest priority queue, one at a time, and push them on the stack. COP3538 Project 2 Stacks and Priority Queues Liu University of North Florida 2 i. Print the stack, then exit the program The queues and the stack should be printed in the following format: Stack Contents: or South Priority Queue Contents: State Name Capital City State Abbr State Population Region US House Seats ------------------------------------------------------------------------------------------------------- Florida Tallahassee FL 19,552,860 South 27 Arkansas Little Rock AR 2,959,373 South 4 Alabama Montgomery AL 4,833,722 South 7 Provide comments in this form for the State, Stack, and Priority classes: Comments for the class: /** * Detailed description of the class. * * @author * @version */ Public method comments: /** * Description of the purpose of the method, the meaning of the * input parameters (if any) and the meaning of the return values * (if any). * * @param parameter description of the parameter (one for each) * @return description of the return value */ Provide comments in this form for the Project2 class. /** * COP 3538: Project 2 Stacks and Priority Queues * * Description of the class using as many lines as needed * with between paragraphs. Including descriptions of the * input required and output generated. * * @author * @version */ public class Project2 { COP3538 Project 2 Stacks and Priority Queues Liu University of North Florida 3 Example: COP3538 Project 2 Instructor: Xudong Liu Stacks and Priority Queues Enter the file name: States2.csv There were 33 state records put on the stack. Stack Contents: State Name Capital City State Abbr State Population Region US House Seats ------------------------------------------------------------------------------------------------------- Wyoming Cheyenne WY 582,658 West 1 Wisconsin Madison WI 5,742,713 Midwest 8 Washington Olympia WA 6,971,406 West 10 . . . South Priority Queue Contents: State Name Capital City State Abbr State Population Region US House Seats ------------------------------------------------------------------------------------------------------- Florida Tallahassee FL 19,552,860 South 27 Georgia Atlanta GA 9,992,167 South 14 . . . West Priority Queue Contents: State Name Capital City State Abbr State Population Region US House Seats ------------------------------------------------------------------------------------------------------- California Sacramento CA 38,332,521 West 53 Washington Olympia WA 6,971,406 West 10 . . . Midwest Priority Queue Contents: State Name Capital City State Abbr State Population Region US House Seats ------------------------------------------------------------------------------------------------------- Illinois Springfield IL 12,882,135 Midwest 18 Ohio Columbus OH 11,570,808 Midwest 16 . . . Stack Contents: State Name Capital City State Abbr State Population Region US House Seats ------------------------------------------------------------------------------------------------------- North Dakota Bismarck ND 723,393 Midwest 1 South Dakota Pierre SD 844,877 Midwest 1 . . . Here is the State class, it needed to be corrected: public class State { private String name, capital, abbrevation, region; private long population; private int houseSeats; public State(String name, String capital, String abbrevation, String region, long population, int houseSeats) { this.name = name; this.capital = capital; this.abbrevation = abbrevation; this.region = region; this.population = population; this.houseSeats = houseSeats; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getCapital() { return capital; } public void setCapital(String capital) { this.capital = capital; } public String getAbbrevation() { return abbrevation; } public void setAbbrevation(String abbrevation) { this.abbrevation = abbrevation; } public String getRegion() { return region; } public void setRegion(String region) { this.region = region; } public long getPopulation() { return population; } public void setPopulation(long population) { this.population = population; } public int compareTo(State other) { return this.getName().compareTo(other.getName()); } public int getHouseSeats() { return houseSeats; } public void setHouseSeats(int houseSeats) { this.houseSeats = houseSeats; } @Override public String toString() { return "State [name=" + name + "(" + abbrevation + "), capital=" + capital + ", " + region + ", population=" + population + "]"; } } And this is the State2.csv file to be read from: State,Capital,Abbreviation,Population,Region,US House Seats Alabama,Montgomery,AL,4833722,South,7 Alaska,Juno,AK,735132,West,1 Arizona,Phoenix,AZ,6626624,Southwest,9 Arkansas,Little Rock,AR,2959373,South,4 California,Sacramento,CA,38332521,West,53 Colorado,Denver,CO,5268367,West,7 Connecticut,Hartford,CT,3596080,New England,5 Delaware,Dover,DE,925749,Middle Atlantic,1 Florida,Tallahassee,FL,19552860,South,27 Georgia,Atlanta,GA,9992167,South,14 Hawaii,Honolulu,HI,1404054,West,2 Idaho,Boise,ID,1612136,West,2 Illinois,Springfield,IL,12882135,Midwest,18 Indiana,Indianapolis,IN,6570902,Midwest,9 Iowa,Des Moines,IA,3090416,Midwest,4 Kansas,Topeka,KS,2893957,Midwest,4 Kentucky,Frankfort,KY,4395295,South,6 Louisiana,Baton Rouge,LA,4625470,South,6 Maine,Augusta,ME,1328302,New England,2 Maryland,Annapolis,MD,5928814,Middle Atlantic,8 Massachusetts,Boston,MA,6692824,New England,9 Michigan,Lansing,MI,9895622,Midwest,14 Minnesota,St Paul,MN,5420380,Midwest,8 Mississippi,Jackson,MS,2991207,South,4 Missouri,Jefferson City,MO,6044171,Midwest,8 Montana,Helena,MT,1015165,West,1 Nebraska,Lincoln,NE,1868516,Midwest,3 Nevada,Carson City,NV,2790136,West,4 New Hampshire,Concord,NH,1323459,New England,2 New Jersey,Trenton,NJ,8899339,Middle Atlantic,12 New Mexico,Santa Fe,NM,2085287,Southwest,3 New York,Albany,NY,19651127,Middle Atlantic,27 North Carolina,Raleigh,NC,9848060,South,13 North Dakota,Bismarck,ND,723393,Midwest,1 Ohio,Columbus,OH,11570808,Midwest,16 Oklahoma,Oklahoma City,OK,3850568,Southwest,5 Oregon,Salem,OR,3930065,West,5 Pennsylvania,Harrisburg,PA,12773801,Middle Atlantic,18 Rhode Island,Providence,RI,1051511,New England,2 South Carolina,Columbia,SC,4774839,South,7 South Dakota,Pierre,SD,844877,Midwest,1 Tennessee,Nashville,TN,6495978,South,9 Texas,Austin,TX,26448193,Southwest,36 Utah,Salt Lake City,UT,2900872,West,4 Vermont,Montpelier,VT,626630,New England,1 Virginia,Richmond,VA,8260405,Middle Atlantic,11 Washington,Olympia,WA,6971406,West,10 West Virginia,Charleston,WV,1854304,Middle Atlantic,3 Wisconsin,Madison,WI,5742713,Midwest,8 Wyoming,Cheyenne,WY,582658,West,1 It would be a good help implementing all the classes in the requirement Thanks

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

State the uses of job description.

Answered: 1 week ago

Question

Explain in detail the different methods of performance appraisal .

Answered: 1 week ago