Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have to write a java program using eclipse. I have to develope a InvalidPositionException.java, Student.Java, and A6YourName.java classes. The Java classes and, txt files

I have to write a java program using eclipse. I have to develope a InvalidPositionException.java, Student.Java, and A6YourName.java classes. The Java classes and, txt files needed are below the instructions. The application showing the report by courses followed by the interactive run using: Adams Benson Manner Washington Ziggy xxx

image text in transcribedimage text in transcribed

IndexedListLinkedList.Java:

public class IndexedListLinkedList implements IndexedList { private LinearNode  head; // reference to first node private LinearNode  tail; // reference to last node private int count; // number of nodes in the list public IndexedListLinkedList ( ) // POST: empty list { head = tail = null; count = 0; } public void addFirst (T element) // POST: element added to front of list { LinearNode newNode = new LinearNode(element); if (isEmpty()) head = tail = newNode; else { newNode.setNext(head); head = newNode; } count++; } public void addLast (T element) // POST: element added to rear of list { LinearNode newNode = new LinearNode(element); if (isEmpty()) head = tail = newNode; else { tail.setNext(newNode); tail = newNode; } count++; } public void add (T element, int position) throws InvalidPositionException { // PRE: 0 = count) // POST: element added at position throw new InvalidPositionException (); if (position == 0) addFirst(element); else if (position == count) addLast(element); else { LinearNode current = head; for (int i = 1; i  newNode = new LinearNode (element); newNode.setNext(current.getNext()); current.setNext(newNode); count++; } } public T removeFirst( ) throws EmptyCollectionException // PRE: list is not empty { // POST: remove and return first element if (isEmpty()) throw new EmptyCollectionException(); LinearNode temp = head; head = head.getNext(); count--; if (isEmpty()) tail = null; T element = temp.getElement(); return element; } public T removeLast( ) throws EmptyCollectionException // PRE: list is not empty { // POST: remove and return last element if (isEmpty( )) throw new EmptyCollectionException( ); LinearNode temp = tail; if (count == 1) head = tail = null; else { LinearNode current = head; for (int k = 0; k= count) throw new InvalidPositionException( ); if (position == 0) return removeFirst( ); else if (position == count-1) return removeLast( ); else { LinearNode previous = head; for (int k = 1; k  current = previous.getNext( ); previous.setNext(current.getNext( )); count--; return current.getElement( ); } } public boolean isEmpty ( ) // POST: return true if list is empty, else false { return count == 0; } public int size( ) // POST: return number of elements in list { return count; } public void clear ( ) // POST: remove all nodes { head = tail = null; count = 0; } public String toString ( ) // POST: return a string representation of list elements { String result = "["; LinearNode current = head; while (current != null) { result = result + " " + current.getElement(); current = current.getNext(); } result = result + " ]"; return result; } // complete the remaining methods public T remove (T element) // POST: remove and return specified element { return null; // return null if element is not found } public T first ( ) throws EmptyCollectionException // PRE: list is not empty { return null; // POST: return first element } public T last ( ) throws EmptyCollectionException // PRE: list is not empty { return null; // POST: return last element } public boolean contains (T target) // POST: return true if list contains target, else false { return true; } public int indexOf (T element ) // POST: return position of element, else -1 { return 0; } public T get (int position) throws InvalidPositionException // PRE: 0  

Courses.txt:

COS103 COS120 COS125 COS213 COS220 COS221 COS225 COS226 COS235 COS250 COS301 COS312 COS331 COS350 COS397 COS412 COS420 COS430 COS440 COS451 COS460 COS470 COS480 COS490 COS497 

students.txt:

Adams COS103 COS213 Benson COS213 COS220 Brown COS103 COS213 Cheng COS301 COS350 COS451 Davis COS440 COS451 COS480 Eghert COS125 COS220 French COS225 COS235 COS312 Georges COS235 COS250 COS312 Heinrich COS301 COS331 COS350 Jackson COS225 COS312 Keller COS235 COS221 COS312 Lee COS125 COS220 Manner COS301 COS331 COS350 COS397 Nelsom COS220 COS225 COS312 Petty COS301 COS331 COS451 Rumer COS397 COS440 COS490 Stein COS301 COS331 COS480 Thompson COS125 COS220 Venner COS221 Washington COS490 COS497 Zaghert COS103
Part II: (80 pts.) In this assignment, remaining methods will be added to the IndexedListLinkedList class developed in lecture. An application is developed that uses this class to maintain student enrollment information 1. Develop the InvalidPositionException class that reports a message on an invalid position for use with the IndexedListLinkedList class. 2. Complete remaining meth class is available on Blackboard attached to the assignment link. ods used in the IndexedListLinkedList class. The partially completed 3. Run the test program A6Tester.java available on Blackboard. Add your name to the top line of output where it says "Your Name". Submit a screen shot only of your output; code is not needed. Tester by Your Name Original list: [ a b c] List after remove: [ab c First element: a Last element: c List contains b List does not contain d Index of b is: 1 Index of d is: -1 String at position 1 is: b List after set position 1 to:[ac 1000 Invalid position Test program is ending 4. Create a class named Student to store data for a student. Data includes a name and a list of courses taken by the student. Use the IndexedListLinkedList class for the list of classes. Include constructors, accessors, and modifier methods. 5. Develop an application named A6YourName.java that uses the IndexedListLinkedList class. File courses.txt contains a list of COS courses. Read theses course names into a String IndexedListLinkedList object. File students.txt contains a list of student names followed by courses taken by that student. Assume names have no blanks. Read student data into a Student IndexedListLinkedList object. Part II: (80 pts.) In this assignment, remaining methods will be added to the IndexedListLinkedList class developed in lecture. An application is developed that uses this class to maintain student enrollment information 1. Develop the InvalidPositionException class that reports a message on an invalid position for use with the IndexedListLinkedList class. 2. Complete remaining meth class is available on Blackboard attached to the assignment link. ods used in the IndexedListLinkedList class. The partially completed 3. Run the test program A6Tester.java available on Blackboard. Add your name to the top line of output where it says "Your Name". Submit a screen shot only of your output; code is not needed. Tester by Your Name Original list: [ a b c] List after remove: [ab c First element: a Last element: c List contains b List does not contain d Index of b is: 1 Index of d is: -1 String at position 1 is: b List after set position 1 to:[ac 1000 Invalid position Test program is ending 4. Create a class named Student to store data for a student. Data includes a name and a list of courses taken by the student. Use the IndexedListLinkedList class for the list of classes. Include constructors, accessors, and modifier methods. 5. Develop an application named A6YourName.java that uses the IndexedListLinkedList class. File courses.txt contains a list of COS courses. Read theses course names into a String IndexedListLinkedList object. File students.txt contains a list of student names followed by courses taken by that student. Assume names have no blanks. Read student data into a Student IndexedListLinkedList object

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

Recommended Textbook for

Database Horse Betting The Road To Absolute Horse Racing 2

Authors: NAKAGAWA,YUKIO

1st Edition

B0CFZN219G, 979-8856410593

More Books

Students also viewed these Databases questions

Question

What is Accounting?

Answered: 1 week ago

Question

Define organisation chart

Answered: 1 week ago

Question

What are the advantages of planning ?

Answered: 1 week ago

Question

Understand how people development is used to retain talent.

Answered: 1 week ago