I'am quite new in java and desperatly need help.
I am trying to implement a studen't print quota.
Printquotaclass:
Expand|Select|Wrap|Line Numbers
- public class printQuota{
- private String studentName;
- private int studentId;
- private int studentBalance;
- private static int unitCost = 2;//unit cost is 2 roubles
- //********************************************************
- // Consttructor sets standard print acc
- //********************************************************
- public printQuota(String student, int id, int initialBalance)
- {
- studentName = student;
- studentId = id;
- studentBalance= initialBalance;
- }
- //-----------------------------------------------------------------
- // Returns the current unit cost.
- //-----------------------------------------------------------------
- public static int getCurrentUnitCost ()
- {
- return unitCost;
- }
- public static int setCurrentUnitCost()
- {
- return unitCost;
- }
- //****************************
- //Increasing Balence
- //*************************
- public int increaseBalance(int amount)
- {
- studentBalance = studentBalance + amount * unitCost;
- return studentBalance;
- }
- //****************************
- //Printing
- //*************************
- public int print(int amount)
- {
- int studentBalence = studentBalance-(amount * unitCost);
- return studentBalence;
- }
- //-----------------------------------------------------------------
- // Returns a one-line description of the account as a string.
- //-----------------------------------------------------------------
- public String toString()
- {
- return " " + studentName + "\t" + studentId + "\t" + studentBalance;
- }
- }
I started the following
[code]import java.util.Scanner
public class printQuotaSystem{
int numaccount = 8;
printQuota[] accounts;
accounts = new printQuota[10]; // allocates memory for 10 account
accounts[0] = new printQuota("jules", 123, 200);
accounts[1] = new printQuota("Dules", 456, 200);
accounts[2] = new printQuota("Gules", 789, 200);
accounts[3] = new printQuota("Hules", 987, 200);
accounts[4] = new printQuota("Bules", 654, 200);
accounts[5] = new printQuota("Eules", 023, 200);
accounts[6] = new printQuota(NULL, 0, 0);
accounts[7] = new printQuota(NULL,0 , 0);
public class addPrintQuota
{
Scanner sc =new Scanner(System.in);
System.out.println("please enter your name");
studentName sc.nextLine();
Scanner sc =new Scanner(System.in)
System.out.println("please enter student ID");
studentName sc.nextInt();
System.out.println("Enter amount of roubles for quot");
for(i=0; i<account.length; i++)
{
if (accounts[i] == NULL)
{
[\code]
my question are:
how to implement the quotaSytem class so that
it add printQuota object to the array?
Thanks