death_entry
03-06-2004, 08:47 AM
I am doing a project based on a leisure centre, where the members must swipe thier cards through a gate, each member has a permission rating (ie 1 2 3) and based on that value the gate allows them acces to the area, so a member with permission level 2 cannot get it into a level 3 permission area.
What i want to do is to have a member object (mr jones, miss collins etc) compare its permission with a specific gate object (eg gate0 gate1, gate2 etc) .
Instead of having the member object having a method (i think that is the right word) for every possible gate, i want the member to be able to type in a string (eg "gate0") and this decides what gate object the permission values are compared too.
If the user does not have the sufficient level of permission the system denies access (note that a level 3 permission gives access to the levels below ie. levels 2 and 1)
I wish to have a messgae that says you went through gate when the permission values are high enough (eg grants acces)
and a message that says you didnt go through the gate (eg denies access) when the permissions are not high enough
This my code for the member class
public class Member
{
public int idNumber;
public String name;
public String type;
public int permission;
public int current_zone;
public String gate;
public Member (int id, String n, String t, int p, int z)
{
idNumber = id;
name = n;
type = t;
permission = p;
current_zone = z;
}
public void enterGatey (String gate)
{
if (gate == "gate0" )
if (Gate.permission_needed >= permission)
System.out.println(" you went through the gate");
Gate.rating = 1;
}
}
This is my code for the Gate class
public class Gate
{
public int gate_number;
public int access_zone;
public int exit_zone;
public static int permission_needed;
public int security;
public static int rating;
public Gate (int gateNumber, int accessZone, int exitZone, int permissionNeeded)
{
gate_number = gateNumber;
access_zone = accessZone;
exit_zone = exitZone;
permission_needed = permissionNeeded;
}
}
The classes compile, but I dont know how to use static variables, dont know what they do really, if i take the statics out then i get an error saying
non-static variable permission_needed cannot be referanced from a static context
If you can help with this then plz post, im in very desperate need of this code. Im using the bluej ide coz my uni forces me too! :D
What i want to do is to have a member object (mr jones, miss collins etc) compare its permission with a specific gate object (eg gate0 gate1, gate2 etc) .
Instead of having the member object having a method (i think that is the right word) for every possible gate, i want the member to be able to type in a string (eg "gate0") and this decides what gate object the permission values are compared too.
If the user does not have the sufficient level of permission the system denies access (note that a level 3 permission gives access to the levels below ie. levels 2 and 1)
I wish to have a messgae that says you went through gate when the permission values are high enough (eg grants acces)
and a message that says you didnt go through the gate (eg denies access) when the permissions are not high enough
This my code for the member class
public class Member
{
public int idNumber;
public String name;
public String type;
public int permission;
public int current_zone;
public String gate;
public Member (int id, String n, String t, int p, int z)
{
idNumber = id;
name = n;
type = t;
permission = p;
current_zone = z;
}
public void enterGatey (String gate)
{
if (gate == "gate0" )
if (Gate.permission_needed >= permission)
System.out.println(" you went through the gate");
Gate.rating = 1;
}
}
This is my code for the Gate class
public class Gate
{
public int gate_number;
public int access_zone;
public int exit_zone;
public static int permission_needed;
public int security;
public static int rating;
public Gate (int gateNumber, int accessZone, int exitZone, int permissionNeeded)
{
gate_number = gateNumber;
access_zone = accessZone;
exit_zone = exitZone;
permission_needed = permissionNeeded;
}
}
The classes compile, but I dont know how to use static variables, dont know what they do really, if i take the statics out then i get an error saying
non-static variable permission_needed cannot be referanced from a static context
If you can help with this then plz post, im in very desperate need of this code. Im using the bluej ide coz my uni forces me too! :D
