Example
#{example}"); ipb.editor_values.get('templates')['togglesource'] = new Template(""); ipb.editor_values.get('templates')['toolbar'] = new Template(""); ipb.editor_values.get('templates')['button'] = new Template("
Emoticons
"); // Add smilies into the mix ipb.editor_values.set( 'show_emoticon_link', false ); ipb.editor_values.set( 'bbcodes', $H({"snapback":{"id":"1","title":"Post Snap Back","desc":"This tag displays a little linked image which links back to a post - used when quoting posts from the board. Opens in same window by default.","tag":"snapback","useoption":"0","example":"[snapback]100[/snapback]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":""},"topic":{"id":"5","title":"Topic Link","desc":"This tag provides an easy way to link to a topic","tag":"topic","useoption":"1","example":"[topic=1]Click me![/topic]","switch_option":"0","menu_option_text":"Enter the topic ID","menu_content_text":"Enter the title for this link","single_tag":"0","optional_option":"0","image":""},"post":{"id":"6","title":"Post Link","desc":"This tag provides an easy way to link to a post.","tag":"post","useoption":"1","example":"[post=1]Click me![/post]","switch_option":"0","menu_option_text":"Enter the Post ID","menu_content_text":"Enter the title for this link","single_tag":"0","optional_option":"0","image":""},"spoiler":{"id":"7","title":"Spoiler","desc":"Spoiler tag","tag":"spoiler","useoption":"0","example":"[spoiler]Some hidden text[/spoiler]","switch_option":"0","menu_option_text":"","menu_content_text":"Enter the text to be masked","single_tag":"0","optional_option":"0","image":""},"acronym":{"id":"8","title":"Acronym","desc":"Allows you to make an acronym that will display a description when moused over","tag":"acronym","useoption":"1","example":"[acronym='Laugh Out Loud']lol[/acronym]","switch_option":"0","menu_option_text":"Enter the description for this acronym (EG: Laugh Out Loud)","menu_content_text":"Enter the acronym (EG: lol)","single_tag":"0","optional_option":"0","image":""},"hr":{"id":"12","title":"Horizontal Rule","desc":"Adds a horizontal rule to separate text","tag":"hr","useoption":"0","example":"[hr]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"1","optional_option":"0","image":""},"php":{"id":"14","title":"PHP Code","desc":"Allows you to enter PHP code into a formatted/highlighted syntax box","tag":"php","useoption":"0","example":"[php]$variable = true;\n\nprint_r($variable);[/php]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":""},"html":{"id":"15","title":"HTML Code","desc":"Allows you to enter formatted/syntax-highlighted HTML code","tag":"html","useoption":"0","example":"[html]\n \n[/html]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":""},"sql":{"id":"16","title":"SQL Code","desc":"Allows you to enter formatted/syntax-highlighted SQL code","tag":"sql","useoption":"0","example":"[sql]SELECT p.*, t.* FROM posts p LEFT JOIN topics t ON t.tid=p.topic_id WHERE t.tid=7[/sql]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":""},"xml":{"id":"17","title":"XML Code","desc":"Allows you to enter formatted/syntax-highlighted XML code","tag":"xml","useoption":"0","example":"[xml]2 Replies - 56 Views - Last Post: Yesterday, 11:18 AM
#1
Reputation: 0
- Posts: 16
- Joined: 12-February 13
Posted Yesterday, 08:39 AM
Hey guys i have come to the forum again for some help and direction. I have an assignment that i need to read in 3 .txt files and remove the middle value for each file and then print the results.Create a linked list to hold the items from the first fi le (input1.txt);
2. Print the linked list;
3. Remove the rst, middle and last items from the linked list;
4. Print the linked list after three items removed;
5. Create a linked list to hold the items from the second file (input2.txt);
6. Print the linked list;
7. Remove the rst, middle and last items from the linked list;
8. Print the linked list after three items removed;
9. Create a linked list to hold the items from the third file (input3.txt);
10. Print the linked list;
11. Remove the first, middle and last items from the linked list;
12. Print the linked list after three items removed;
Now we are told to use 3 methods with this program.
1. public static LinkedList<String> readItems(String fileName);
2. public static void removeFirstMiddleLast(LinkedList<String> l);
3. public static void printListWithSeparator(LinkedList<String> l);
As i make my programs i like to get the basic setup done first before i get into depth with everything else. So what i have done is basically create the whole program under my whole main method. Which so far is working, but i am having issues turning it back into the 3 methods that i need. Seeing how the first method is only using one file at a time. I am assuming i need to use a loop of some sort. Also i have no finished the "1 main method" because i figured i would start moving towards the direction of the 3 methods.
import java.io.*; import java.util.*; public class Test { public static void main(String [] arg) throws FileNotFoundException { int count1 = 0; int count2 = 0; int count3 = 0; LinkedList<String> list1 = new LinkedList<String>(); LinkedList<String> list2 = new LinkedList<String>(); LinkedList<String> list3 = new LinkedList<String>(); //File Reader File file1 = new File("E:\\Programming 2\\eclipse\\Assignment 6\\input1.txt"); Scanner f1 = new Scanner(file1); String f1Contents; while(f1.hasNext()) { count1++; f1Contents = f1.next(); list1.add(f1Contents); } File file2 = new File("E:\\Programming 2\\eclipse\\Assignment 6\\input2.txt"); Scanner f2 = new Scanner(file2); String f2Contents; while(f2.hasNext()) { count2++; f2Contents = f2.next(); list2.add(f2Contents); } File file3 = new File("E:\\Programming 2\\eclipse\\Assignment 6\\input3.txt"); Scanner f3 = new Scanner(file3); String f3Contents; while(f3.hasNext()) { count3++; f3Contents = f3.next(); list3.add(f3Contents); } f1.close(); f2.close(); f3.close(); //Link List Creation ListIterator<String> iterator1 = list1.listIterator(); while(iterator1.hasNext()) { String l1 = iterator1.next(); System.out.print(l1+" "); } System.out.println(""); ListIterator<String> iterator2 = list2.listIterator(); while(iterator2.hasNext()) { String l2 = iterator2.next(); System.out.print(l2+" "); } System.out.println(""); ListIterator<String> iterator3 = list3.listIterator(); while(iterator3.hasNext()) { String l3 = iterator3.next(); System.out.print(l3+" "); } } }
I also have attached the output file/input1/input2/input3. So you all can see what the files are that i am dealing with and what the output needs to look like.
Thanks all in advance,
Jars
Is This A Good Question/Topic? 0
Replies To: Linked Lists
#2
Reputation: 5353
- Posts: 8,569
- Joined: 19-March 11
Re: Linked Lists
Posted Yesterday, 09:18 AM
So you've established the proof of concept and now you want to make it clean? Probably easiest to start from scratch, honestly, and do it right from the start this time. You have three methods required. Start by writing stubs for each of those. Here, I'll give you those:public static LinkedList<String> readItems(String fileName) { LinkedList<String> list = new LinkedList<String>(); list.add("foo"); list.add("bar"); list.add("baz"); return list; } public static void removeFirstMiddleLast(LinkedList<String> l) { return; } public static void printListWithSeparator(LinkedList<String> l) { return; }
Then, make the methods work. You can use your main method to test them, if you want, or you can write test methods for them and call them from main.
Finally, write code in main that calls these methods to meet the assignment requirements.
#3
Reputation: 0
- Posts: 16
- Joined: 12-February 13
Re: Linked Lists
Posted Yesterday, 11:18 AM
Figured it out
This post has been edited by Jars: Yesterday, 11:30 AM
Page 1 of 1
Source: http://www.dreamincode.net/forums/topic/320408-linked-lists/
12 12 12 Anne Hathaway Wardrobe Malfunction Adrienne Maloof Telemundo real housewives of beverly hills Pink Floyd 12 12 12 Concert
No comments:
Post a Comment