Changed folder structure

This commit is contained in:
2023-09-21 12:43:40 +03:00
parent dd86d669bf
commit fad1a8e284
6 changed files with 10 additions and 6 deletions

View File

@@ -0,0 +1,33 @@
package com.faf223.expensetrackerfaf.model;
public class Categories {
public enum ExpenseCategory {
CREDIT, BUY, BUSINESS, ENTERTAINMENT, RESTAURANTS_AND_CAFE, COMMUNAL_PAYMENTS, SUPERMARKET, MISC;
public String getEffectiveName() {
return Categories.getEffectiveName(this.name());
}
}
public enum IncomeCategory {
P2P, SALARY, GIFT, CREDIT, MISC;
public String getEffectiveName() {
return Categories.getEffectiveName(this.name());
}
}
private static String getEffectiveName(String name) {
String[] arr = name.split("_");
StringBuilder result = new StringBuilder();
for(String entry : arr) {
String[] entryArr = entry.split("");
StringBuilder builder = new StringBuilder(entryArr[0]);
for(int i = 1; i < entry.length(); i++) builder.append(entryArr[i].toLowerCase());
result.append(builder).append(" ");
}
return result.toString();
}
}

View File

@@ -0,0 +1,43 @@
package com.faf223.expensetrackerfaf.model;
import com.faf223.expensetrackerfaf.util.IMoneyTransaction;
public class Expense implements IMoneyTransaction {
private int userId;
private int amount;
private Categories.ExpenseCategory category;
public Expense(int userId, int amount, Categories.ExpenseCategory category) {
this.userId = userId;
this.amount = amount;
this.category = category;
}
@Override
public long getUserId() {
return userId;
}
public void setUserId(int userId) {
this.userId = userId;
}
@Override
public int getAmount() {
return amount;
}
public void setAmount(int amount) {
this.amount = amount;
}
@Override
public String getCategory() {
return category.getEffectiveName();
}
public void setCategory(Categories.ExpenseCategory category) {
this.category = category;
}
}

View File

@@ -0,0 +1,43 @@
package com.faf223.expensetrackerfaf.model;
import com.faf223.expensetrackerfaf.util.IMoneyTransaction;
public class Income implements IMoneyTransaction {
private long userId;
private int amount;
private Categories.IncomeCategory category;
public Income(long userId, int amount, Categories.IncomeCategory category) {
this.userId = userId;
this.amount = amount;
this.category = category;
}
@Override
public long getUserId() {
return userId;
}
@Override
public int getAmount() {
return amount;
}
@Override
public String getCategory() {
return category.getEffectiveName();
}
public void setUserId(long userId) {
this.userId = userId;
}
public void setAmount(int amount) {
this.amount = amount;
}
public void setCategory(Categories.IncomeCategory category) {
this.category = category;
}
}

View File

@@ -0,0 +1,7 @@
package com.faf223.expensetrackerfaf.model;
public enum Role {
UNREGISTERED, REGISTERED, ADMIN;
}

View File

@@ -0,0 +1,88 @@
package com.faf223.expensetrackerfaf.model;
import java.util.List;
public class User {
private long id;
private String name, email, login, password;
private Role role;
private List<Expense> expenses;
private List<Income> incomes;
public User(long id, String name, String email, String login, String password, Role role, List<Expense> expenses, List<Income> incomes) {
this.id = id;
this.name = name;
this.email = email;
this.login = login;
this.password = password;
this.role = role;
this.expenses = expenses;
this.incomes = incomes;
}
public User() {}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getLogin() {
return login;
}
public void setLogin(String login) {
this.login = login;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public Role getRole() {
return role;
}
public void setRole(Role role) {
this.role = role;
}
public List<Expense> getExpenses() {
return expenses;
}
public void setExpenses(List<Expense> expenses) {
this.expenses = expenses;
}
public List<Income> getIncomes() {
return incomes;
}
public void setIncomes(List<Income> incomes) {
this.incomes = incomes;
}
}