Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - P1C0

Pages: [1]
1
Java / Re: Programming Help!
« on: November 30, 2011, 02:56:57 pm »
Ok I got it  :D  I just had to change the regiment class and implement it on the army class. I'll come back if I need more help. Thanks again!  :D

2
Java / Re: Programming Help!
« on: November 30, 2011, 02:12:01 pm »
Thanks for the reply!  :)  But I try it and it doesn't work  :(  The men number is not found on the txt file, I must figure out a way to do it, but I'm not sure how to update it and on which part of the program. The first regiment will have 1000 men, the second one will have 950, the third will have 900...etc. There are 20 regiments. I have try everything I could think of...if,for, do while, etc for it but it doesn't seen to update the list of men.


I did do some weird stuff that I erase that work...but when I try to change the some values some crazy numbers appears.

3
Java / Re: Programming Help!
« on: November 30, 2011, 06:27:08 am »
Here is part of the code:


Army Class

Code: [Select]

public static void main(String[] args) throws IOException {
        Army superArmy = new Army();
        Scanner fileScan = new Scanner(new File("regiments.txt"));
        while (fileScan.hasNext()) // while not eof
        {
            int regimentNumber = fileScan.nextInt();
            String name = fileScan.next();
            int men = 1000;
            Regiment next = new Regiment(regimentNumber, name, men);
            superArmy.AddRegiment(next);
        }
        superArmy.PrintList();
}



Code: [Select]
public void PrintList() {
       
        for (int i = 0; i < regiment.size(); i++) {
            Regiment more = regiment.get(i);
           
            System.out.println("Regiment Number: " + "[" + more.getRegimentNumber() + "]"
                    + " Regiment Name: " + "[" + more.getName() + "]"
                    + " Number Of Men: " + "[" + more.getNumberOfMen() + "]");
        }
    }


There is another class "Regiment" which has return values...but I don't think we have to update it(I think not sure). Also the code is a lot bigger but these are the specific parts I'm having trouble on. How would I update the men value so it decreases by lets say 50 for each regiment(1000, 950, 900, 850, etc)

4
Java / Programming Help!
« on: November 30, 2011, 06:19:50 am »
I have a question...how would you update a value inside an array. Lets say I have tester, and two other classes. The tester class reads a txt file that contains 2 of 3 different items. The third item I have to update. But the problem is that the tester class has the initial value of the third item(since its a number)...but when I try to print the list, it wont let me update because the initial value always appears instead of updating.


How would I do this.... Its a programming assig and is driving me crazy  :-\


Any help is appreciated!  :) 

Pages: [1]