[text] tyu

Viewer

  1. package com3;
  2.  
  3. public class CellPhoneDemo {
  4.  
  5.         public static void main(String[] args) {
  6.                 Cell[] cells = new Cell[5];
  7.                 cells[0] = new Cell(1,"aaa",50,0.5,"mum");
  8.                 cells[1] = new Cell(2,"aaa",40,0.5,"ahd");
  9.                 cells[2] = new Cell(3,"aaa",30,0.5,"pne");
  10.                 cells[3] = new Cell(4,"aaa",55,0.5,"mum");
  11.                 cells[4] = new Cell(5,"aaa",60,0.5,"pne");
  12.                 System.out.println(deductBalance(cells[0],10));
  13.                 Cell[] newCells = searchCircle(cells,"mum");
  14.                 for(Cell cell:newCells)
  15.                 {
  16.                 System.out.println(cell.getCellNo());
  17.         }
  18.         }
  19.         public static double deductBalance(Cell cell, int seconds) {
  20.                 double oldBalance = cell.getBalance();
  21.                 double newBalance = oldBalance - (cell.getRatePerSecond()*seconds);
  22.                 return newBalance;
  23.         }
  24.         public static Cell[] searchCircle(Cell[] cells, String circlename) {
  25.                 int i = 0;
  26.                 Cell[] newArray = new Cell[2];
  27.                 for (Cell c: cells) {
  28.                         if(c.getCircle()==circlename) {
  29.                                 newArray[i] = c;
  30.                                 i++;
  31.                         }
  32.                 }
  33.                 return newArray;
  34.         }
  35. }
  36.  
  37.  
  38.  

Editor

You can edit this paste and save as new:


File Description
  • tyu
  • Paste Code
  • 16 Sep-2019
  • 989 Bytes
You can Share it: