Advertisement
Guest User

Untitled

a guest
Dec 10th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.30 KB | None | 0 0
  1. package data;
  2.  
  3. import java.util.Map;
  4.  
  5. // Time-window statistics
  6. public class Statistic extends TableObject {
  7. private static final int DEFAULT_ID = -1;
  8.  
  9. private int totalRevenue;
  10. private int totalExpense;
  11. private int totalProfit;
  12.  
  13. public Statistic(){
  14. super(DEFAULT_ID);
  15. }
  16.  
  17. public Statistic(int totalRevenue, int totalExpense, int totalProfit){
  18. super(DEFAULT_ID);
  19. this.totalRevenue = totalRevenue;
  20. this.totalExpense = totalExpense;
  21. this.totalProfit = totalProfit;
  22. }
  23. public Statistic(int id, int totalRevenue, int totalExpense, int totalProfit){
  24. super(id);
  25. this.totalRevenue = totalRevenue;
  26. this.totalExpense = totalExpense;
  27. this.totalProfit = totalProfit;
  28. }
  29. protected Statistic(int ID) {
  30. super(ID);
  31. }
  32.  
  33. @Override
  34. public int getUniqueColumnIndex() {
  35. return 0;
  36. }
  37.  
  38. @Override
  39. public int getColumnCount() {
  40. return 3;
  41. }
  42.  
  43. @Override
  44. public String[] getColumnNames() {
  45. return new String[]{"totalRevenue", "totalExpense", "totalProfit"};
  46. }
  47.  
  48. @Override
  49. public String[] getColumnTypes() {
  50. return new String[]{"INTEGER","INTEGER","INTEGER"};
  51. }
  52.  
  53. @Override
  54. public Object[] getColumnValues() {
  55. return new Object[]{totalRevenue,totalExpense,totalProfit};
  56. }
  57.  
  58. @Override
  59. protected TableObject rebuild(Map<String, Object> values) {
  60. int _id = (int) values.get(ID_COLUMN);
  61. int _totalRevenue = (int) values.get("totalRevenue");
  62. int _totalExpense = (int) values.get("totalExpense");
  63. int _totalProfit = (int) values.get("totalProfit");
  64. return new Statistic(_id,_totalRevenue,_totalExpense,_totalProfit);
  65. }
  66.  
  67. public int getTotalRevenue() {
  68. return totalRevenue;
  69. }
  70.  
  71. public void setTotalRevenue(int totalRevenue) {
  72. this.totalRevenue = totalRevenue;
  73. }
  74.  
  75. public int getTotalExpense() {
  76. return totalExpense;
  77. }
  78.  
  79. public void setTotalExpense(int totalExpense) {
  80. this.totalExpense = totalExpense;
  81. }
  82.  
  83. public int getTotalProfit() {
  84. return totalProfit;
  85. }
  86.  
  87. public void setTotalProfit(int totalProfit) {
  88. this.totalProfit = totalProfit;
  89. }
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement