-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 3c23b1d
Showing
9 changed files
with
127 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Project exclude paths | ||
/out/ |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module type="JAVA_MODULE" version="4"> | ||
<component name="NewModuleRootManager" inherit-compiler-output="true"> | ||
<exclude-output /> | ||
<content url="file://$MODULE_DIR$"> | ||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> | ||
</content> | ||
<orderEntry type="inheritedJdk" /> | ||
<orderEntry type="sourceFolder" forTests="false" /> | ||
</component> | ||
</module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
public class Debt { | ||
|
||
private final String CURRENCY = "PLN"; | ||
|
||
private String reciver; | ||
private String giver; | ||
private int amount; | ||
|
||
public Debt(String reciver, String giver, int amount) { | ||
this.reciver = reciver; | ||
this.giver = giver; | ||
this.amount = amount; | ||
} | ||
|
||
@Override | ||
public String toString(){ | ||
|
||
return this.giver + " owes " + this.reciver + " " + this.amount + " " + CURRENCY; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
public class DebtCalculator { | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import java.io.BufferedReader; | ||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.regex.Pattern; | ||
|
||
public class FileReader { | ||
|
||
private final String FILE_FOLDER = "src/files/"; | ||
private final String FilePath; | ||
|
||
public FileReader(String filePath) { | ||
FilePath = filePath; | ||
} | ||
|
||
public ArrayList<Person> readPersonsFromFile() throws IOException { | ||
|
||
ArrayList<Person> persons = new ArrayList<>(); | ||
BufferedReader br = new BufferedReader(new java.io.FileReader(FILE_FOLDER + FilePath)); | ||
String line; | ||
|
||
while ((line = br.readLine()) != null) { | ||
if(line.charAt(0) == '#'){ //lines starting with '#' are ignored | ||
continue; | ||
} | ||
String[] info = line.split(Pattern.quote("|")); | ||
persons.add(new Person(info[0], Integer.parseInt(info[1]), Double.parseDouble(info[2]))); | ||
} | ||
|
||
return persons; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import java.util.regex.Pattern; | ||
|
||
public class Main { | ||
|
||
public static void main(String[] args){ | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import java.util.ArrayList; | ||
|
||
public class Person { | ||
|
||
private final String name; | ||
private final int expense; | ||
private final double ratio; | ||
private int balance; | ||
|
||
|
||
public Person(String name, int expense, double ratio) { | ||
this.name = name; | ||
this.expense = expense; | ||
this.ratio = ratio; | ||
this.balance = 0; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public int getExpense() { | ||
return expense; | ||
} | ||
|
||
public double getRatio() { | ||
return ratio; | ||
} | ||
|
||
public int getBalance() { | ||
return balance; | ||
} | ||
|
||
public void setBalance(int balance) { | ||
this.balance = balance; | ||
} | ||
} |