/Users/johnr/Desktop/IA pdf Downloads/Criteria__P__-_Coding_Project_Upload_all_2022-05-03/ia2_Sorn/src/main/java/com/mycompany/ia2/UserStat.java
 1 /*
 2  * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 3  * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
 4  */
 5 package com.mycompany.ia2;
 6 import java.util.LinkedList;
 7 import java.text.DecimalFormat;
 8 
 9 /**
10  *
11  * @author 21015
12  */
13 public class UserStat {
14     
15     //Setting Up Variable
16     private String agent;
17     private int kill = 0;
18     private int death = 0;
19     private int assist = 0;
20     private boolean win = false;
21     private int gameNumber;
22     private int id;
23     
24     //Setting Decimal to 2 Places
25     private static DecimalFormat dfSharp = new DecimalFormat("#.##");
26     
27     //Empty Constructor
28     UserStat(){
29         
30     }
31     
32     //Setter Constructor Without ID
33     UserStat(String agent, int kill, int death, int assist, boolean win){
34         this.agent = agent;
35         this.kill = kill;
36         this.death = death;
37         this.assist = assist;
38         this.win = win;
39     }
40     
41     //Setter Constructor
42     UserStat(String agent, int kill, int death, int assist, boolean win, int gameNumber, int id){
43         this.agent = agent;
44         this.kill = kill;
45         this.death = death;
46         this.assist = assist;
47         this.win = win;
48         this.gameNumber = gameNumber;
49         this.id = id;
50     }
51     
52     //Getter
53     public  String getAgent(){
54         return this.agent;
55     }
56     public  int getKill(){
57         return this.kill;
58     }
59     public  int getDeath(){
60         return this.death;
61     }
62     public  int getAssist(){
63         return this.assist;
64     }
65     public  boolean getWin(){
66         return this.win;
67     }
68     public  int getID(){
69         return this.id;
70     }
71     public String[] getDataAsString(){
72         String temp[] = {String.valueOf(gameNumber), agent, String.valueOf(kill), String.valueOf(death), String.valueOf(assist), String.valueOf(win), String.valueOf(calKDA())};
73         return temp;
74     }
75     
76     //Claculating KDA Method
77     public  double calKDA() {
78         return Double.parseDouble(dfSharp.format((double) (kill+assist)/death));
79     }
80 }
81