User Profile

Collapse

Profile Sidebar

Collapse
yolkman
yolkman
Last Activity: Nov 27 '06, 03:32 PM
Joined: Sep 14 '06
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • yolkman
    started a topic help with linked lists
    in Java

    help with linked lists

    I have a constructor public LinkedList(int[]) that will read primitive values in an array and place them in a linked list. How do I go about this?
    See more | Go to post

  • returning element at a certain position in a linked list

    I have a linked list that contains 28 integer values. The method getPostion has an int as a parameter. I know that it will probably be easier to use an iterator to loop through each element in the list but I don't know to set it up. Could you provide me with an example as to how I would do this?
    See more | Go to post

  • yolkman
    replied to dividing a linked list
    in Java
    I already figured it out, but thanks for your help anyway....
    See more | Go to post

    Leave a comment:


  • yolkman
    started a topic dividing a linked list
    in Java

    dividing a linked list

    Let's say you have a linked list that contains 1, 2 , 3, 4, 5 , 6, 7

    How would you divide the linked list at 4 where the old linked list will have 1, 2, 3 while the new linked list would return 4, 5, 6, 7?
    See more | Go to post

  • yolkman
    replied to help with singly linklists
    in Java
    I got it to work now. Thanks for your help!...
    See more | Go to post

    Leave a comment:


  • yolkman
    replied to help with singly linklists
    in Java
    It didn't give me the printout 7 6 4 5 3 2 1 0
    Instead it printed out 7 6 5 4 3 2 1 0...
    See more | Go to post

    Leave a comment:


  • yolkman
    replied to help with singly linklists
    in Java
    I've modified the code some more and now instead of printing out 7 6 5 4 3 2 1 0
    i get 7 6 4 5. How do I get the 3 2 1 and 0 to show after the 5?

    Code:
    Node previous=first;
    Node current=first.next;
    
    while(current.data!=5 and current!=null){
    previous=current;
    current=previous.next;
    }
    
    previous.next=current.next;
    previous.next.next=new Node(5);
    See more | Go to post

    Leave a comment:


  • yolkman
    replied to help with singly linklists
    in Java
    I've got it to the point now where instead of displaying: 7 6 5 4 3 2 1 0
    it says 7 6 5 3 2 1 0. However the 4 doesn't show up between the 6 and the 5.

    Code:
    while(position.data!=5 && position!=null){
    	
    	position=position.next;
    	
    	previous=position;
    	
    	}
    	
    	
    	position.next=position.next.next;
    	
    	
    	
    	
    	
    	}
    See more | Go to post

    Leave a comment:


  • yolkman
    started a topic help with singly linklists
    in Java

    help with singly linklists

    We were giving a sample link list to play around with for class. When running the program, the last line of the print out says:

    List After adding a Node: 7 6 5 4 3 2 1 0

    However I added a method called stepOne that is suppose to swap positions of the 5 and the 4 in order that it would print out

    List After adding a Node: 7 6 4 5 3 2 1 0

    However I don't get this print out.

    ...
    See more | Go to post

  • I am unclear as to what you have just said....
    See more | Go to post

    Leave a comment:


  • I've finished all the code but I can't get the "X" and "O"s to show up on the board or to switch between human players.

    Code:
    package csc216.project2;
    
    import javax.swing.JOptionPane;
    
    
    
    
    public class TicTacToe implements GameBoard{
    	
    	private GameCanvas canvas;
    	
    	private String [] [] board;
    	
    	private String currentPlayer;
    ...
    See more | Go to post

    Leave a comment:


  • I have a boolean method named makeMove that tries to make a move and returns true if the move is valid and false if it isn't.

    I also have a public String promptMove() method that prompts a player to move a piece on the board.

    Code:
    	public boolean makeMove( String move ){
    		
    		
    		for(int row=0; row<3; row++){
    		
    		
    			for(int col=0; col<3; col++){
    ...
    See more | Go to post

    Leave a comment:


  • yolkman
    started a topic switching between 2 people in TicTacToe.java
    in Java

    switching between 2 people in TicTacToe.java

    How do you alternate between 2 human players?
    See more | Go to post

  • reading an inventory.txt file and placing the price and item into an array

    The text file is below:

    21.95 Water Filter Pack
    .51 Pork and Beans
    1.79 Chicken Salad Sandwich
    5.99 Coke 24-pack
    3.79 Barbara's Oat Bran Cereal
    2.19 Sandwich Bags
    1.07 Potato Chips

    Here is part of my code to read the text file.

    Code:
        try{
    		   FileReader fr=new FileReader(filename);
    		   BufferedReader br=new BufferedReader(fr);
    ...
    See more | Go to post
No activity results to display
Show More
Working...