Well I have a question and not sure if it's right. Here's the question(Long one).
Applications. Build a class called Precinct. The record for a voter will consist of aname (String) and a political party(Boolean)(Two party). The SignInQueue method takes two parameters, a voter name and a party, and places this voter in a queue of those waiting to sign in. This SignInComplete method removes the voter at the front of the sign-in queue and places that voter into either the queue waiting to vote for the true party or the queue waiting to vote for the false party, depending on the voter's party. The TrueDone method removes the voter from the queue waiting to vote for the true party and returns the name of the voter. THe FalseDone method removes the voter from the queue waiting to vote for the false party and returns the name of that voter.

I have to start this from scratch, and well I finished it, and wanted to see if my methods were right Here is my code:

public class Precinct
{
    private static class Record
    {
    Public String Name;
    Public Boolean Party;

    Public Record(String voter, Boolean Group)
    {
        Name = voter;
        Party = Group;
    }
    Public Record(Record Item)
    {
    Name = Item.Name;
    Party = Item.Party;
    }
    }

public void SignInQueue(String Name, Boolean Party)
    {
    Record A = new Record(Name, Party)
    WaitingSignIn.Store(A); //This is where the voter will be in queue

    }

public void SignInComplete()
    {
        Record A = WaitingSignIn.Retrieve(); //retrieves the queue waiting in line
        if(Party = True)
        {
            RegisterTrue.Store(A); //They'll be in another queue
            WaitingSignIn.Delete(); //removes the voter from waiting in line
        }
        else
            RegisterFalse.STore(A); //another queue
            WaitingSignin.Delete(); //same as above the if statement
        }

public String TrueDone()
    {
    RegisterTrue.Retrieve(A);
    RegisterTrue.Delete();
    return A.Name; //returns with the voter and party.
    }

public String FalseDone()
    {
    RegisterFalse.Retreive(A);
    RegisterFalse.Delete();
    return A.Name;
    }

    private Queue<Precinct> WaitingSignIn = new queue<Precinct>();
    private Queue<Precinct> RegisterTrue = new queue<Precinct>();
    private Queue<Precinct> RegisterFalse = new queue<Precinct>();
}

Any feedback is appreciated. This question is mostly about on queue/java util while using the linux program.

Recommended Answers

All 4 Replies

Obviously you haven't compiled this code, let alone tested it.
Before you ask people to spend time looking at it, take the time to compile it and fix all the compiler errors that you can. If you can fix them all (which yu should be able to do) the write a really simple main method that tests you code with a simple test case.
Take that process as far as you can, then when you get stuck come back here for help.

To help you get started with the compile...
1. Java is case-sensitive. Queue and queue are not the same. By convention class names are captialised, variables and methods are not.
2. Read the API documentation for Queue to find the correct names for its methods

This is the sample exam study guide, where the exam questions requires us to write out the answer with pencil, rather than working on the computer. I didn't compile it because I just wrote this while answering the 14 Exam questions, and I got stuck and decided just to post what I wrote. I was just wanted to know if my methods were right and made sense.

But i will take your words in consideration and I have the time for it, i'll try compiling it and post later.

OK, thanks for explaining that.
In that case I would say the logic looks reasonable once you fix the names and capitalisation.

commented: Alright thanks for help :) +1

Alright i'm going to mark this question solved. Thanks for the tips, I will rework on my name and capatalization. I voted up on your comment :P

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.