1 Replies - 251 Views - Last Post: 21 March 2019 - 10:40 AM Rate Topic: -----

#1 kretze   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 35
  • Joined: 22-October 18

queue is abstract

Posted 21 March 2019 - 10:16 AM

hey guys i have a one proble in ATMSIM class on 28 line i have a this error Queue is abstract cannot be instatiated..can anyone help me??

class costumer
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package atm;

import java.util.Random;

/**
 *
 * @author dejan
 */
public class costumer {
    private int arrivalTime;
    private int serviceTime;
    
    public costumer()
    {
        arrivalTime=0;
        serviceTime=0;
    }
    public costumer(int arrTime)
    {
        arrivalTime=arrTime;
        Random r=new Random();
        serviceTime=r.nextInt(3)+1;
        
        
    }
    public void setArrivalTime(int arrtime)
    {
        arrivalTime=arrtime;
    }
    public void setServiceTime(int sTime)
    {
        serviceTime=sTime;
    }
    public int getArrivaltime()
    {
        return arrivalTime;
    }
    public int getServicetime()
    {
        return serviceTime;
    }
    
}




class ATMSIM
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package atm;

import java.util.Queue;
import java.util.Random;

/**
 *
 * @author dejan
 */
public class ATMSIM {
    costumer c;
    int ATMisValible;
    int numArivals;
    Queue<costumer>que;
    int totalWaitingtime;
    int numcostumerserved;
    public ATMSIM()
    {
        ATMisValible=0;
        numArivals=0;
        totalWaitingtime=0;
        numcostumerserved=0;
       que = new Queue<costumer>(200);
       
        
    }
    private int getAriivals()
    {
        Random r=new Random();
        int randomInteger=r.nextInt(10);
        if(randomInteger<=4)
            return 0;
        if(randomInteger<=8)
            return 1;
        
            return 2;
        
        
    }
    
    private void display()
    {
        System.out.println("Number of customers served" +numcostumerserved);
        System.out.println("average wait is about "+totalWaitingtime/numcostumerserved + "minutes");
        System.out.println("costumer left in queue "+que.size());
    }
            
    
}




Is This A Good Question/Topic? 0
  • +

Replies To: queue is abstract

#2 NormR   User is offline

  • D.I.C Lover
  • member icon

Reputation: 765
  • View blog
  • Posts: 5,762
  • Joined: 25-December 13

Re: queue is abstract

Posted 21 March 2019 - 10:40 AM

Quote

Queue is abstract cannot be instatiated

You can not create new instances of an abstract class or interface.
Read the API doc for the Queue interface and find a useful class that implements the Queue interface.

This post has been edited by NormR: 21 March 2019 - 10:43 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1