Hi, so this is my final assignment for the semester so I thought I would setup a thread for it now because I will probably need a fair bit of ongoing help. (Thank you in advance to anyone that does give me a hand).
Website of project: Java Programming (CITS1200)

Basically I need to make a program that takes in the candidates name from an external text file. And then takes in the votes from a separate text file.
I need 3 classes:
* Vote - will represent a single vote and its preferences.
* Candidate - will represent a single candidate and their votes.
* Election - will represent an election process.

I've been supplied this code (Which is apparently for reading text files):

The project says I need to use SimpleCanvas which is just a graphical interface for BlueJ. But I'm planning on just focusing on getting the coding down pact. And then I can sort that stuff out later, because it's not really an important aspect in the scheme of things.

If anyone has tips on where to start off it'd be much appreciated. According to my lecturer, Vote should be and easy class, Candidate a little bit harder, and Election the hardest.
Not too good when I'm not entirely sure what I should be doing for vote? Haha.
I'm sure people know how it is, a push and a shove and I'll keep on rolling:) Just no way of getting started on the hill. (Quite proud of that analogy)

Thanks very much,
Regard, Tom.

May 6th, 2009, 04:38 AM

JavaPF

Re: Election Program - Ongoing

Hello bruint,

Is the FileIO class an example or does this have to be included into the project?

May 6th, 2009, 04:55 AM

bruint

Re: Election Program - Ongoing

Included in the project:)

May 11th, 2009, 02:03 AM

bruint

Re: Election Program - Ongoing

Apologies for the double post, but I needed to bump this.
I still don't know where to start. Any help, is very much appreciated.

Just focussing on the vote class at the moment.

May 11th, 2009, 06:46 AM

JavaPF

Re: Election Program - Ongoing

Hello bruint,

This looks complicated!! My brain is in no fit state this morning to be working this out lol

I've read through it but i'm still unsure as to how it's ment to work (:|

Hi JavaPF, thanks for getting back to me. But whilst I understand the structure of Java programs, I just don't know where to start in regards to what I need to do to go about taking what I get from FileIO and analysing it...

:)

May 11th, 2009, 07:16 AM

JavaPF

Re: Election Program - Ongoing

Quote:

Originally Posted by bruint

Hi JavaPF, thanks for getting back to me. But whilst I understand the structure of Java programs, I just don't know where to start in regards to what I need to do to go about taking what I get from FileIO and analysing it...

:)

I'm still trying to figure out what needs to go into FileIO in the first place.

So lets start with the Vote class. If you understand this, then what is the Vote class ment to do?

May 11th, 2009, 07:42 AM

bruint

Re: Election Program - Ongoing

the Vote class takes from a text file, one line of letters say:
ACBDE
This represents one individuals vote.
A is one candidate, B is another, C is another, etc.

The vote class checks that it is a formal vote first, record if it isn't. To be a formal vote it must have the number of Candidates as explained by a candidates text file which will only have one line of letters ABCDE.
If a voter has AcBDE, their vote is informal, if a voter has ABCD their vote is informal.

The vote goes like this
1. A
2. B
3. C
4. D
5. E

It reads through all the votes in the text file, if D gets the least number of 1's then they aren't going to win, so for this voter, their D vote would be given to E. And this would be done for a number of people. Eg.
1. D
2. B
3. C
4. E
5. A
This persons D vote would be given to B.

1. B
2. C
3. D
4. E
5. A
This persons D vote would be given to E.

May 11th, 2009, 08:23 AM

JavaPF

Re: Election Program - Ongoing

OK well to start we should use the Small example election text files.

So we need to read in the candidates file first? CS.txt

To do this, we need to give the file name to the FileIO constructor. If the Vote class is our main starting point:

probably use the charAt [0], charAt[1], etc. to find which each is equal to and store each as a Char variable and then compare them to each new vote in the list seperately by using a loop that ends when it is equal to the noOfLines from fileIO?

Can I just say THANKS SO MUCH for giving your time up for me:)

Does what I explained above sound correct?

May 11th, 2009, 09:42 AM

JavaPF

Re: Election Program - Ongoing

Quote:

Originally Posted by bruint

probably use the charAt [0], charAt[1], etc. to find which each is equal to and store each as a Char variable and then compare them to each new vote in the list seperately by using a loop that ends when it is equal to the noOfLines from fileIO?

Can I just say THANKS SO MUCH for giving your time up for me:)

Does what I explained above sound correct?

Yes that sounds good.

You seem to know exactly what is expected here which is a lot more than I can say for me!

See how far you can get with it and I will help if I can when you get stuck..

May 11th, 2009, 09:46 AM

bruint

Re: Election Program - Ongoing

haha, no, you've been a ton of help *clicks thanks*

Thanks very much. Be back here soon enough:)

May 17th, 2009, 11:16 PM

bruint

Re: Election Program - Ongoing

ok. So I've worked on it a bit more with my friend who's done the course before (But a completely different project)
Vote:

If you refer to my Original Post there is a ton of information in there.

If someone could read through the Vote class and check for problems that may occur, and also help me with those 2 methods I mentioned above.

Thanks very much to any help you can offer :) This is due on friday, so I'm beginning to get a bit..worried about it all as I'm a bit stumped. If it is of any help, election is one of the main classes, the other two are however important as they supply a number of helper methods.