Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

editing no git project #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 0 additions & 30 deletions .gitignore

This file was deleted.

5 changes: 0 additions & 5 deletions README.md

This file was deleted.

158 changes: 70 additions & 88 deletions src/Moudle/Account.Java
Original file line number Diff line number Diff line change
@@ -1,154 +1,136 @@
package Moudle;

import Controller.ControlBox;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Account {
private static ArrayList<Account> accounts;
private String username;
private String password;
private static ArrayList<Account> accounts = new ArrayList<>();
private String userName;
private String passWord;
private Collection collection;
private int money;
private ArrayList<Deck> decks;
private Deck mainDeck;
private int wins;
private int losses;
private static int inputType; //0:nothing's happened, 1:username's been added, 2:password's been added

public static void input(ControlBox controlBox) {
int input = inputType;
if (controlBox.getType().equals("createAccount")) {
if(input == 1){

if(input == 2){

}
}
}
public String getUserName() {
return userName;
}

public boolean isValidDeck() {
return false;
public void setUserName(String userName) {
this.userName = userName;
}

public String getUsername() {
return username;
public Collection getCollection() {
return collection;
}

public void setCollection(Collection collection) {
this.collection = collection;
public int getMoney() {
return money;
}

public void setMoney(int money) {
this.money = money;
}

public void addDeck(Deck deck) {
this.decks.add(deck);
public void addMoney(int money) {
this.money += money;
}

public void setMainDeck(Deck deck) {
this.mainDeck = deck;
public void spendMoney(int money) {
this.money -= money;
}

public Collection getCollection() {
return collection;
public ArrayList<Deck> getDecks() {
return decks;
}

public int getMoney() {
return money;
}

public void spendMoney(int price) {
money -= price;
public Deck getMainDeck() {
return mainDeck;
}

public void addMoney(int price) {
money += price;
public void setMainDeck(Deck mainDeck) {
this.mainDeck = mainDeck;
}

public ArrayList<Deck> getDecks() {
return decks;
public int getWins() {
return wins;
}

public Deck getMainDeck() {
return mainDeck;
public int getLosses() {
return losses;
}

public static void createAccount(String username) {
Scanner scanner = new Scanner(System.in);
int accountFounded = 0;
for (int i = 0; i < accounts.size(); i++) {
if (accounts.get(i).username.equals(username)) {
accountFounded = 1;
public static Account findAccount(String userName) {
if (accounts.size() == 0) {
return null;
} else {
for (int i = 0; i < accounts.size(); i++) {
if (accounts.get(i).userName.equals(userName)) {
return accounts.get(i);
}
}
}
if (accountFounded == 1) {
System.out.println("This user has already been created!");
return null;
}

public static void createAccount(String userName) {
if (findAccount(userName) != null) {
System.out.println("There is an account with this userName!");
} else {
String password = scanner.next();
Scanner scanner = new Scanner(System.in);
String passWord = scanner.next();
Account account = new Account();
account.username = username;
account.password = password;
account.userName = userName;
account.passWord = passWord;
accounts.add(account);
System.out.println("created");
}

}

public static void login(String username) {
Scanner scanner = new Scanner(System.in);
int accountFounded = 0;
for (int i = 0; i < accounts.size(); i++) {
if (accounts.get(i).username.equals(username)) {
accountFounded = 1;
}
}
if (accountFounded == 0) {
System.out.println("There is no such username!");
public boolean login(String userName) {
if (findAccount(userName) == null) {
System.out.println("There is no account with this userName!");
return false;
} else {
String password = scanner.next();
for (int i = 0; i < accounts.size(); i++) {
if (accounts.get(i).password.equals(password)) {

} else {
System.out.println("Wrong password!");
}
Scanner scanner = new Scanner(System.in);
String passWord = scanner.next();
if (passWord.equals(findAccount(userName).passWord)) {

return true;
} else {
System.out.println("Wrong passWord!");
return false;
}
}
}

public void logout() {

}

public static void save() {

}

public void increaseWins() {
wins++;
}

public void increaseLosses() {
losses++;
}

public static void showLeaderBoard() {
for (int i = 0; i < accounts.size(); i++) {
for (int j = i + 1; j < accounts.size(); j++) {
if (accounts.get(i).wins < accounts.get(j).wins) {
if (accounts.get(j).wins > accounts.get(i).wins) {
Collections.swap(accounts, i, j);
}
}
}
for (int i = 0; i < accounts.size(); i++) {
System.out.println(i + "-" + "UserName" + ":" + accounts.get(i).username + "-" + "Wins" + ":" + accounts.get(i).wins);
System.out.printf("%d-UserName : %s-Wins : %d\n", i + 1, accounts.get(i).userName, accounts.get(i).wins);
}
}

public void help() {
System.out.println("create account [user name]\nlogin [user name]\nshow leaderboard\nsave\nlogout\n");
public static void save() {

}

public static void logout() {

}

public static void help() {
System.out.print("create account [user name}\nlogin [user name]\nshow leaderboard\nsave\nlogout\nhelp\n");
}
}
}
Loading