Swap two elements - java

I wrote a simple easy code to exchange two elemnts in a list, that looks like this:
public void swap(Item a, Item aprev, Item b, Item bprev){
aprev.next = b;
bprev.next = a;
}
Now. If i want to actually swap two elements, nothing really changes. So if I do this:
SelectionSortableList list = new SelectionSortableList();
Item item = list.new Item("4");
Item item1 = list.new Item("5");
Item item2 = list.new Item("6");
Item item3 = list.new Item("7");
list.addFront(item.value);
list.addFront(item1.value);
list.addFront(item2.value);
list.addFront(item3.value);
System.out.println(list.toString());
list.swap(item1, item, item3, item2);
System.out.println(list.toString());
/* */ public abstract class SinglyLinkedList
/* */ {
/* */ protected SinglyLinkedList.Item head;
/* */
/* */ public void addFront(String s) {
/* 6 */ if (head == null) {
/* 7 */ head = new SinglyLinkedList.Item(s);
/* */ }
/* */ else {
/* 10 */ SinglyLinkedList.Item insert = new SinglyLinkedList.Item(s);
/* 11 */ next = head;
/* 12 */ head = insert;
/* */ }
/* */ }
/* */
/* */ public void add(String[] array) { String[] arrayOfString;
/* 17 */ int j = (arrayOfString = array).length;
for (int i = 0; i < j; i++) { String s = arrayOfString[i];
/* 18 */ addFront(s);
/* */ }
/* */ }
/* */
/* */ public String toString()
/* */ {
/* 24 */ if (head == null) {
/* 25 */ return "empty list";
/* */ }
/* 27 */ String s = "";
/* */
/* 29 */ for (SinglyLinkedList.Item helper = head; next != null;
helper = next) {
/* 30 */ s = String.valueOf(s) + value + ", ";
/* */ }
/* 32 */ s = String.valueOf(s) + value;
/* 33 */ return s;
/* */ }
/* */
/* */ public abstract void sort();
/* */
/* */ protected class Item
/* */ {
/* */ public Item next;
/* */ public String value;
/* */
/* */ public Item(String value) {
/* 44 */ this.value = value;
/* */ }
/* */ }
/* */ }
Sorry for that mess, but it is a decompiled jar. And here is my yet unfinished class:
public class SelectionSortableList extends SinglyLinkedList{
public Item head;
public SelectionSortableList(){
this.head = new Item(null);
}
public void swap(Item a, Item aprev, Item b, Item bprev){
aprev.next = b;
bprev.next = a;
}
Nothing changes and he prints me the exact same list, as before. I really have no clue, why this doesn't work.It would be great, if somebody can give me a tip, or maybe if I should write a little bit more. Thank you in beforehand :)

First, it would be good to mention, why you have to or choose to go this way, instead of using a class from the Java Collections Framework.
But even if you do it for educational purposes, e.g. learn about list data structures and algorithms operating on the list, I'd recommend to first program it with the standard Java API, such as in this example.
Then, to understand what's going on inside, follow the source of the used classes. You'll find it at the OpenJDK project or for example nicely browsable here.
When having understood that, you can go back and implement your own version of it and (if you for example have to) use the given data structure.
Concerning your specific problem - I haven't tried it out (you should do that by debugging as suggested before), but I assume that when extending the class and using the same member variable name, you shadow the base class one and thus don't operate on it. So you should extend functionality, but work on the same data structure.

Related

Calling insertion sort class from driver doesn't work

The bubble sort sorting in the driver class works fine but I make a new list and try to do insertion sort and it just doesn't sort the list. I was thinking it was something with the setSortBehavior method in the first Listing class but everything I've tried hasn't worked.
package strategydesignpattern;
import java.util.ArrayList;
public class Listing {
protected String title;
protected ArrayList<String> items;
protected SortBehavior theSortBehavior;
/**
* Creates a list with the indicated name
* #param title The title of the list
*/
public Listing(String title)
{
this.title = title;
this.items = new ArrayList<String>();
this.theSortBehavior = new BubbleSort();
}
/**
* Adds an item to the list
* #param item the item you want to add to the list
*/
public void add(String item)
{
items.add(item);
}
/**
* removes an item from the list
* #param item the item you want to remove from the list
*/
public void remove(String item)
{
items.remove(item);
}
/**
* a getter for the name of the list
* #return returns the title of the list
*/
public String getTitle()
{
return title;
}
/**
* sets the sort behavior to whatever is passed in
* #param sortBehavior gets the sort behavior, either insertion or bubble
*/
public void setSortBehavior(SortBehavior sortBehavior)
{
theSortBehavior = sortBehavior;
}
/**
*
* #return returns the sorted list of items
*/
public ArrayList<String> getSortedList()
{
return theSortBehavior.sort(items);
}
/**
*
* #return returns the unsorted list of items
*/
public ArrayList<String> getUnSortedList()
{
return items;
}
}
//////
package strategydesignpattern;
import java.util.ArrayList;
public interface SortBehavior {
public ArrayList<String> sort(ArrayList<String> data);
}
///
package strategydesignpattern;
import java.util.ArrayList;
public class BubbleSort implements SortBehavior{
public ArrayList<String> sort(ArrayList<String> data)
{
String temp;
boolean sorted = false;
while (!sorted) {
sorted = true;
for (int i = 0; i < data.size()-1; i++) {
if (data.get(i).compareTo(data.get(i + 1)) > 0) {
temp = data.get(i);
data.set(i, data.get(i + 1));
data.set(i + 1, temp);
sorted = false;
}
}
}
return data;
}
}
//
package strategydesignpattern;
import java.util.ArrayList;
public class InsertionSort implements SortBehavior{
public ArrayList<String> sort(ArrayList<String> data)
{
for (int j = 1; j < data.size(); j++) {
String current = data.get(j);
int i = j-1;
while ((i > -1) && ((data.get(i).compareTo(current)) == 1)) {
data.set(i+1, data.get(i));
i--;
}
data.set(i+1, current);
}
return data;
}
}
////
package strategydesignpattern;
import java.util.ArrayList;
/**
* Creates lists of information, and displays the sorted versions of the lists
*/
public class ListDriver {
/**
* Creates a new ListDriver
*/
public ListDriver(){}
/**
* Main entryway to the program
* Creates the lists, and displays the sorted lists
*/
public void run() {
Listing shoppingList = new Listing("Grocery List");
shoppingList.add("Apples");
shoppingList.add("Peaches");
shoppingList.add("Cheese");
shoppingList.add("Crackers");
shoppingList.add("Chocolate");
shoppingList.add("Cherries");
shoppingList.add("Bananas");
shoppingList.add("Oranges");
ArrayList<String> sortedGroceryItems = shoppingList.getSortedList();
System.out.println(shoppingList.getTitle());
displayList(sortedGroceryItems);
Listing wishList = new Listing("Wish List");
wishList.setSortBehavior(new InsertionSort());
wishList.add("Bike");
wishList.add("Paddle Board");
wishList.add("Boat");
wishList.add("Truck");
wishList.add("Puzzle");
wishList.add("Monolopy");
wishList.add("Skipping Rope");
wishList.add("Cherry Tree");
ArrayList<String> sortedWishListItems = wishList.getSortedList();
System.out.println("\n" + wishList.getTitle());
displayList(sortedWishListItems);
}
/**
* Loops through and displays each item in the list items
* #param items list to display
*/
private void displayList(ArrayList<String> items){
for(String item : items){
System.out.println("- " + item);
}
}
public static void main(String[] args){
ListDriver driver = new ListDriver();
driver.run();
}
}
It appears that you have assumed the String.compareTo will return 1 to indicate a lexicographical ordering where the string the method is being invoked on follows the argument string. The Documenation states that the return value for String.compareTo is a positive integer to indicate this lexicographical ordering, not specifically 1.
I have try to debug your code. I find that (data.get(i).compareTo(current)) == 1) is not correct. According to the Java String API (https://docs.oracle.com/javase/10/docs/api/java/lang/String.html#compareTo(java.lang.String))
The result is a negative integer if this String object lexicographically precedes the argument string. The result is a positive integer if this String object lexicographically follows the argument string. The result is zero if the strings are equal; compareTo returns 0 exactly when the equals(Object) method would return true.
It says the result is a positive integer.

Im having a problem with my iterator reading more than 3 items

So I have looked over this code for the past couple hours and cannot find the bug. Subset takes in an array for 3 String characters and it will read through and print them out fine, but if I add more than three elements it kicks out an arrayoutofbounds exception and I cannot figure out why. I can manually add them in one by one and it will work but thats not the way that the program was designed to work. Im sure the solution is simple but I cannot find it. Any ideas? Thanks so much.
package a02;
import java.util.Iterator;
import edu.princeton.cs.algs4.StdRandom;
/**
*
* #author Danny
*
* #param <Item>
*/
public class RandomizedQueue<Item> implements Iterable<Item> {
private Item[] queue ;
private int size;
/**
* Constructs an empty randomized queue.
*/
public RandomizedQueue() {
queue = (Item[])new Object[1];
size=0;
}
/**
* parameterized constructor for the Iterator class.
* #param array
*/
private RandomizedQueue(Item[] array)
{
int count = 0;
queue = array;
while(queue[count]!=null)
count++;
queue = (Item[])new Object[array.length];
for(int i=0;i<count;i++)
queue[i]=array[i];
size=count;
}
private Item[] getArray() {
return queue;
}
/**
* Checks to see if the queue is empty.
* #return
*/
public boolean isEmpty() {
return size<=0;
}
/**
* Returns the number of items in the queue.
* #return
*/
public int size() {
return size;
}
/**
* Adds an item.
* #param item
*/
public void enqueue(Item item) {
if (item == null)
throw new java.lang.NullPointerException();
if (size == queue.length)
resize(2*queue.length);
queue[size]= item;
size++;
}
/**
* Deletes and returns a random item
* #return
*/
public Item dequeue() {
if (isEmpty())
throw new java.util.NoSuchElementException();
int index = StdRandom.uniform(size);
Item item = queue[index];
if(index == size-1)
queue[index] = null;
else {
queue[index] = queue[size-1];
queue[size-1]=null;
}
size--;
if(size<=queue.length/4)
resize(queue.length/2);
return item;
}
/**
* Returns a random item, but does not delete it.
* #return
*/
public Item sample() {
if (isEmpty())
throw new java.util.NoSuchElementException();
int index = StdRandom.uniform(size);
return queue[index];
}
/**
* Returns an independent iterator over items in random order.
*/
public Iterator<Item> iterator(){
return new RandomizedQueueIterator();
}
/**
*
* #author Danny
*
*/
private class RandomizedQueueIterator implements Iterator<Item>{
RandomizedQueue<Item> rq = new RandomizedQueue<>(queue);
#Override
public boolean hasNext() {
return rq.size()!=0;
}
#Override
public Item next() {
return rq.dequeue();
}
#Override
public void remove() {
throw new java.lang.UnsupportedOperationException();
}
}
/**
* Resizes the queue array by the given size.
* #param d
*/
private void resize(int d) {
Item[] newArray = (Item[]) new Object[d];
for(int i = 0;i<size;i++)
newArray[i]=queue[i];
queue = newArray;
}
/**
* Unit Testing
* #param args
*/
public static void main(String[] args) {
RandomizedQueue<Integer> rq = new RandomizedQueue<>();
rq.enqueue(1);
rq.enqueue(2);
rq.enqueue(3);
rq.enqueue(4);
rq.enqueue(5);
rq.enqueue(6);
rq.enqueue(7);
Iterator<Integer> iterator1 = rq.iterator();
while(iterator1.hasNext())
System.out.println(iterator1.next());
System.out.println();
Iterator<Integer> iterator2 = rq.iterator();
while(iterator2.hasNext())
System.out.println(iterator2.next());
}
}
package a02;
import java.util.Iterator;
public class Subset {
public static void main(String[] args) {
//char [] c = {'b', 'a', 'C'};
String[] c= {"hello", "hi", "howdy", "english"};
RandomizedQueue<String> queue = new RandomizedQueue<String>();
for (int i=0;i<c.length; i++)
queue.enqueue(c[i]);
int k=3;
Iterator<String> iterator=queue.iterator();
for (int i=0; i<k;i++) {
System.out.println(iterator.next());
}
}
}
In the constructor RandomizedQueue(Item[] array) you need to add a bounds check before accessing queue.
Change:
while(queue[count]!=null)
to
while(count < queue.length && queue[count]!=null)

putting data into array and then JTable

Referring to an earlier question i asked
lining up data in console output java
I wish to put my output in an array so that i can then further put this into a JTable
The extract for my code so far is, i am currently printing out the output to the console.
String assd = null;
String eventy = null;
String assdFT = null;
for (int i = 0; i < list.getLength(); i++) {
Element element = (Element)list.item(i);
String nodeName = element.getNodeName();
switch (nodeName) {
case "assd":
assd = element.getChildNodes().item(0).getNodeValue();
break;
case "eventy":
eventy = element.getChildNodes().item(0).getNodeValue();
break;
case "assdFT":
assdFT = element.getChildNodes().item(0).getNodeValue();
break;
System.out.printf("%-30s %-20s %s%n", assd, eventy,assdFT);
Object[][] data = {{assd, eventy,assdFT}};//this only appears to put the elements in row 1, since System.out.println(data[1][0]) causes an out of array exception but System.out.println(data[0][0]) prints out all the elements of assd
To put data directly into a JTable pass an instance of your custom AbstractTableModel to the JTable constructor. Within TableModel, you can define what data is displayed and how it is accessed.
It would probably look something like this:
public class HeaderTableModel extends AbstractTableModel {
/**
*
*/
private static final long serialVersionUID = 8974549762036798969L;
private Object[][] myData;
public HeaderTableModel(final Object[][] theRows) {
myHeaderRows = theRows;
}
/*
* (non-Javadoc)
*
* #see javax.swing.table.TableModel#getColumnCount()
*/
#Override
public int getColumnCount() {
return LocalStorage.getNumColumns();
}
/*
* (non-Javadoc)
*
* #see javax.swing.table.TableModel#getRowCount()
*/
#Override
public int getRowCount() {
return LocalStorage.getNumRows();
}
/*
* (non-Javadoc)
*
* #see javax.swing.table.TableModel#getValueAt(int, int)
*/
#Override
public Object getValueAt(final int theRow, final int theColumn) {
return myHeaderRows[theRow][theColumn];
}

Trying to get this linked list started

Second programming class
So we have been tasked with a linked list, building each method from scratch.
Well I started on this day before yesterday and had a null pointer exception, I figured id iron it out later and continued.
Well after cutting my program down to nothing to find the culprit im left with code that SHOULD work as its copied from our lab (that worked).
If you guys think you can figure out why im getting a null pointer exception on my add method id greatly appreciate it and see if im doing the second constructor correctly. If I can get SOME traction on this to get started it would go allot easier but as is I cant even begin.
You will notice allot of blank methods, ill get to them once I can get my constructor + add method working
My code:
import java.util.Collection;
import java.util.Iterator;
/**
* Created by hhhh on 11/2/2014.
*/
public class Lset<R> implements Set151Interface<R> {
private Node head;
private int length;
/**In the first (following) constructor im trying to re use code and call my clear method.
*Should save space and make code look cleaner.
*/
public Lset(){
clear();
}
public Lset(Collection<? extends R> list){
this();
for (R object : list) {
add(object);
}
}
/**
* Copied from Lab7, this add method checks to see if there are more nodes than just the head.
* After the check if false, creates a new node and adds it to the end of the list.
* #param entry
* #return
*/
#Override
public boolean add(R entry) {
Node newNode = new Node(entry);
// empty list is handled differently from a non-empty list
if (head.next == null) {
head = newNode;
} else {
Node lastNode = getNodeAt(length - 1);
lastNode.next = newNode;
}
length++;
return true;
}
#Override
public void clear() {
this.length = 0;
this.head = null;
}
#Override
public boolean contains(Object o) {
return false;
}
#Override
public Iterator<R> iterator() {
return null;
}
#Override
public boolean containsAll(Collection<?> c) {
return false;
}
#Override
public boolean isEmpty() {
return false;
}
#Override
public boolean remove(Object o) {
return false;
}
#Override
public boolean addAll(Collection<? extends R> c) {
return false;
}
#Override
public boolean removeAll(Collection<?> c) {
return false;
}
#Override
public boolean retainAll(Collection<?> c) {
return false;
}
#Override
public int size() {
return length;
}
#Override
public Object[] toArray() {
return null;
}
#Override
public <T> T[] toArray(T[] array) {
return null;
}
/**
* Code used in Lab 7, getNodeAt uses the length field and starts at head to traverse array and arrive at the
* position desired.
* #param position
* #return
*/
private Node getNodeAt(int position) {
assert !isEmpty() && (position >= 0) && position < length;
Node cNode = head;
for (int i = 0; i < position; i++)
cNode = cNode.next;
assert cNode != null;
return cNode;
}
public String toString(){
String arrayString = "<";
for(int i = 0; i < length; i++){
String two = getNodeAt(i).toString();
arrayString += two;
if(i <= (length - 2)){
two = ", ";
arrayString += two;
}
}
arrayString += ">";
return arrayString;
}
//TODO comment better
public class Node {
/** Reference to the data */
public R data;
/** Reference to the next node is in the list */
public Node next;
/**
* Sets the data for this node.
* #param data data to be carried by this node.
*/
public Node(R data) {
this.data = data;
this.next = null;
}
/**
* Sets the data for the node and assigns the next node in the list.
* #param data data to be carried by this node.
* #param nextNode next node in the list.
*/
public Node(R data, Node nextNode) {
this.data = data;
this.next = nextNode;
}
/**
* Returns just the data portion of the node.
* #return The data portion of the node.
*/
public R getData() {
return this.data;
}
/**
* Modified just the data portion of the node.
* #param data new data to be contained within the node.
*/
public void setData(R data) {
this.data = data;
}
/**
* What node does this node point to.
* #return the node that this node points to or null if it does not
* point anywhere.
*/
public Node getNextNode() {
return this.next;
}
/**
* Change the node that this node points to.
* #param nextNode a new node for this node to point to.
*/
public void setNextNode(Node nextNode) {
this.next = nextNode;
}
/**
* Display the state of just the data portion of the node.
*/
public String toString() {
return this.data.toString();
}
}
}
This is the method in main thats killing it
private void testConstruction() {
System.out.println("\nTesting Constructor");
System.out.print("----------------------------------------");
System.out.println("----------------------------------------");
Set151Interface s = makeSet();
//added
s.add("Butterfinger");
test(s.size() == 0,
"size() should return 0: " + s.size());
test(s.toString().equals("<>"),
"toString returns \"<>\": " + s.toString());
ArrayList<String> temp = new ArrayList<String>();
temp.add("Butterfinger");
temp.add("Milky Way");
temp.add("Kit Kat");
temp.add("Three Muskateers");
Set151Interface s3 = makeSet(temp);
test(s3.size() == 4,
"size should return 4: " + s3.size());
test(s3.toString().equals("<Butterfinger, Milky Way, Kit Kat, Three Muskateers>"),
"toString should return\n "+
"\"<Butterfinger, Milky Way, Kit Kat, Three Muskateers>\":\n "
+ s3.toString());
}
as soon as butterfinger attempts to get added I get null pointer exception pointing to this line
if (head.next == null) {
You just declared private Node head; and it doesnt takes any value assigned . so the compiler throws NPE
Thanks for the help guys, I figured it out :).
On day one I had edited my driver (and forgot) once I re copied the driver everything works (so far) thanks again guys!

How do I call methods from a class with an arraylist to another class?

I'm in my first semester of Java and I need help in calling methods from the VotingMachine class below to the Candidate Class. The Voting Machine class is compiling properly. Thank you all for any help you can provide....
Mercedes
import java.util.ArrayList;
/**
* These are the fields for the Voting Machine Class.
*/
public class VotingMachine
{
private ArrayList<String> candidateList;
/**
* The following constructor will establish the Candidate List
*/
public VotingMachine()
{
candidateList = new ArrayList<String>();
}
/**
* This constructor will store the Candidates for the Candidate List
*/
public void setCandidateList()
{
candidateList.add("Darnell Woffard");
candidateList.add("Barack Obama");
candidateList.add("Hillary Clinton");
}
/**
* This method will display the entire Candidate List.
*/
public void printCandidateInfo()
{
for (int index=0; index < candidateList.size(); index++)
{
System.out.println(candidateList.get(index));
}
}
/**
* Method to the number of Candidates in the CandidateList Arraylist.
*/
public int getNumberofFiles()
{
return candidateList.size();
}
/**
* Method to select one candidate by first providing an index number.
*/
public void listFile(int index)
{
if(index >= 0 && index < candidateList.size()){
String filename = candidateList.get(index);
System.out.println(filename);
}
}
/**
* This method will enable a user to remove a candidate.
*/
public void removeFile(int index)
{
if(index >= 0 && index < candidateList.size()){
candidateList.remove(index);
}
}
/**
* This method will add a file to the Candidate List.
*
*/
public void addCandidate(String filename)
{
candidateList.add(filename);
}
//----------
//The Candidate Class:
public class Candidate{
private String name;
private char party;
private String candidateList;
// Add fields
/**
* Fields
* name - Candidate's name, stored in a String
* party - Candidate's political party, stored in a char
* as 'r' for Republican, 'd' for Democrat, and 'i' for Independent
*/
/**
* Constructor
*
* #param anyName - caller inputs Candidate name
* #param anyParty - caller inputs Candidate's party affiliation
* stored as a char
* chars are assigned with single quotes.
*/
public Candidate(String anyName, char anyParty)
{
name = anyName;
party = anyParty;
}
/**
* The method will enable method calls from the Voting Machine Class.
*/
public void main(String candidateList)
{
VotingMachine votingMachine = new VotingMachine();
}
/**
* This method will define the candidates party affiliation.
* public char setParty()
*/
//Complete the three methods and their comments.
/**
* Method to retrieve the Candidate's name for the caller.
* public String getName(String anyName)
*
*/
/**
* Method to retrieve the Candidate's party for the caller.
*
* #return
*/
/**
* Method to change the Candidate's party
*
* #param
*/
Actually what i got from this is you are trying to make a voting machine. VotingMachine is the main class here having info of different candidates. so we will make object of candidate in votingMachine class. Note: when we are supposed to make a java project, figure out what is it main class and subclass that means which depends on which. in the above example There is association in the classes. First of all declare an ArrayList for storing objects of candidate class. as shown below.
private ArrayList<candidate> candidateList;
/**
* The following constructor will establish the Candidate List
*/
public VotingMachine()
{
candidateList = new ArrayList<String>();
}
now for adding new candidate in the ArrayList I have modified your method
setCandidate()
as
public void addNewCandidate(String name, char partySymbol)
{
candidate candid = new candidate(name, partySymbol);// this will call the candidate constructor
candidateList.add(candid);//add that object in ArrayList
}
As ArrayList stores references of objects, the built-in function int get(int index) will return the reference of the object. to print the info of that object or you can say values, we should define a function as getName() and getParty(). instead of this System.out.println(candidateList.get(index)); you should call System.out.println(candidateList.get(index).getName()); and System.out.println(candidateList.get(index).getParty());in the following method
public void printCandidateInfo()
{
for (int index=0; index < candidateList.size(); index++)
{
System.out.println(candidateList.get(index));
}
}
so define functions in candidate class as
public String getName()
{
return name;
}
/**
* Method to retrieve the Candidate's party for the caller.
*
* #return
*/
public char getParty()
{
return party;
}
the following method will print the reference not the info of candidate, so modify it as described above
public void listFile(int index)
{
if(index >= 0 && index < candidateList.size()){
String filename = candidateList.get(index);
System.out.println(filename);
}
}
as i have modified it,
import java.util.ArrayList;
/**
* These are the fields for the Voting Machine Class.
*/
public class VotingMachine
{
private ArrayList<Candidate> candidateList;
/**
* The following constructor will establish the Candidate List
*/
public VotingMachine()
{
candidateList = new ArrayList<>();
}
/**
* This method will store the Candidates for the Candidate List
*/
public void addNewCandidate(String name, char partySymbol)
{
Candidate candid = new Candidate(name, partySymbol);// this will call the candidate constructor
candidateList.add(candid);//add that object in ArrayList
}
/**
* This method will display the entire Candidate List.
*/
public void printCandidateInfo()
{
for (int index=0; index < candidateList.size(); index++)
{
System.out.print(candidateList.get(index).getName());
System.out.println(" " + candidateList.get(index).getParty());
}
}
/**
* Method to the number of Candidates in the CandidateList Arraylist.
*/
public int getNumberofFiles()
{
return candidateList.size();
}
/**
* Method to select one candidate by first providing an index number.
*/
public void listFile(int index)
{
System.out.print(candidateList.get(index).getName());
System.out.println(" " + candidateList.get(index).getParty());
}
/**
* This method will enable a user to remove a candidate.
*/
public void removeFile(int index)
{
if(index >= 0 && index < candidateList.size()){
candidateList.remove(index);
}
}
}
in candidate class i have just added the above mentioned getName() and getParty() methods..
regards

Categories