-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from solvena/Diagrams
Diagrams
- Loading branch information
Showing
35 changed files
with
3,726 additions
and
2,492 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,3 @@ | ||
| { | ||
| "java.checkstyle.configuration": "/google_checks.xml" | ||
| } |
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,101 @@ | ||
| <?xml version="1.0"?> | ||
| <!DOCTYPE module PUBLIC | ||
| "-//Puppy Crawl//DTD Check Configuration 1.3//EN" | ||
| "https://checkstyle.org/dtds/configuration_1_3.dtd"> | ||
|
|
||
| <!-- | ||
| Google's Java Style Guide: https://google.github.io/styleguide/javaguide.html | ||
| --> | ||
| <module name="Checker"> | ||
| <property name="charset" value="UTF-8"/> | ||
| <property name="severity" value="warning"/> | ||
| <property name="fileExtensions" value="java,properties,xml"/> | ||
|
|
||
| <!-- Excludes all 'module' directory --> | ||
| <module name="BeforeExecutionExclusionFileFilter"> | ||
| <property name="fileNamePattern" value="module\-info\.java$"/> | ||
| </module> | ||
|
|
||
| <!-- File length --> | ||
| <module name="FileLength"> | ||
| <property name="max" value="2000"/> | ||
| <property name="severity" value="ignore"/> | ||
| </module> | ||
|
|
||
| <!-- Line length --> | ||
| <module name="LineLength"> | ||
| <property name="max" value="100"/> | ||
| <property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/> | ||
| </module> | ||
|
|
||
| <!-- No trailing whitespace --> | ||
| <module name="RegexpSingleline"> | ||
| <property name="format" value="\s+$"/> | ||
| <property name="message" value="Line has trailing spaces."/> | ||
| </module> | ||
|
|
||
| <!-- No tabs --> | ||
| <module name="RegexpSingleline"> | ||
| <property name="format" value="^\t+"/> | ||
| <property name="message" value="Line contains tabs."/> | ||
| </module> | ||
|
|
||
| <module name="TreeWalker"> | ||
| <!-- Imports --> | ||
| <module name="AvoidStarImport"/> | ||
| <module name="RedundantImport"/> | ||
| <module name="UnusedImports"/> | ||
|
|
||
| <!-- Javadoc --> | ||
| <module name="JavadocMethod"> | ||
| <property name="accessModifiers" value="public"/> | ||
| <property name="severity" value="warning"/> | ||
| <property name="allowMissingParamTags" value="false"/> | ||
| <property name="allowMissingReturnTag" value="false"/> | ||
| </module> | ||
| <module name="JavadocType"> | ||
| <property name="severity" value="warning"/> | ||
| </module> | ||
| <module name="JavadocStyle"> | ||
| <property name="checkFirstSentence" value="true"/> | ||
| </module> | ||
|
|
||
| <!-- Naming conventions --> | ||
| <module name="TypeName"> | ||
| <property name="format" value="^[A-Z][a-zA-Z0-9]*$"/> | ||
| </module> | ||
| <module name="MethodName"> | ||
| <property name="format" value="^[a-z][a-zA-Z0-9]*$"/> | ||
| </module> | ||
| <module name="ConstantName"> | ||
| <property name="format" value="^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$"/> | ||
| </module> | ||
| <module name="LocalVariableName"> | ||
| <property name="format" value="^[a-z]([a-z0-9][a-zA-Z0-9]*)?$"/> | ||
| </module> | ||
| <module name="MemberName"> | ||
| <property name="format" value="^[a-z]([a-z0-9][a-zA-Z0-9]*)?$"/> | ||
| </module> | ||
| <module name="ParameterName"> | ||
| <property name="format" value="^[a-z]([a-z0-9][a-zA-Z0-9]*)?$"/> | ||
| </module> | ||
|
|
||
| <!-- Whitespace --> | ||
| <module name="GenericWhitespace"/> | ||
| <module name="MethodParamPad"/> | ||
| <module name="NoWhitespaceAfter"> | ||
| <property name="tokens" value="BNOT,DEC,DOT,INC,LNOT,UNARY_MINUS,UNARY_PLUS"/> | ||
| </module> | ||
| <module name="NoWhitespaceBefore"/> | ||
| <module name="OperatorWrap"/> | ||
| <module name="ParenPad"/> | ||
| <module name="TypecastParenPad"/> | ||
|
|
||
| <!-- Other checks --> | ||
| <module name="EmptyBlock"/> | ||
| <module name="NeedBraces"/> | ||
| <module name="OneStatementPerLine"/> | ||
| <module name="EqualsHashCode"/> | ||
| <module name="StringLiteralEquality"/> | ||
| </module> | ||
| </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
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 |
|---|---|---|
| @@ -1,37 +1,58 @@ | ||
| package Controller; | ||
| import java.nio.file.*; | ||
|
|
||
| import Model.Stock; | ||
| import java.io.IOException; | ||
| import java.math.BigDecimal; | ||
| import java.nio.file.*; | ||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
|
|
||
| import Model.Stock; | ||
|
|
||
| /** | ||
| * Handles loading and saving Stock data from/to CSV files. | ||
| * The CSV format is: ticker,company_name,price | ||
| * Lines starting with '#' are treated as comments and ignored. | ||
| */ | ||
| public class StockFileHandler { | ||
|
|
||
| // lesing | ||
| public List<Stock> loadStocksFromFile(String filename) throws IOException { | ||
| return Files.readAllLines(Paths.get(filename)).stream() | ||
| .map(String::trim) | ||
| .filter(line -> !line.isEmpty() && !line.startsWith("#")) | ||
| .map(line -> line.split(",")) | ||
| .filter(parts -> parts.length == 3) | ||
| .map(parts -> new Stock(parts[0], parts[1], new BigDecimal(parts[2]))) | ||
| .toList(); | ||
| } | ||
| /** | ||
| * Loads stocks from a CSV file. | ||
| * Expected format: ticker,company,price | ||
| * Empty lines and lines starting with '#' are ignored. | ||
| * | ||
| * @param filename the path to the CSV file | ||
| * @return a list of Stock objects loaded from the file | ||
| * @throws IOException if the file cannot be read | ||
| */ | ||
| public List<Stock> loadStocksFromFile(String filename) throws IOException { | ||
| return Files.readAllLines(Paths.get(filename)).stream() | ||
| .map(String::trim) | ||
| .filter(line -> !line.isEmpty() && !line.startsWith("#")) | ||
| .map(line -> line.split(",")) | ||
| .filter(parts -> parts.length == 3) | ||
| .map(parts -> new Stock(parts[0], parts[1], new BigDecimal(parts[2]))) | ||
| .toList(); | ||
| } | ||
|
|
||
| // lagring | ||
| public void saveStocksToFile(String filename, List<Stock> stocks) throws IOException { | ||
| List<String> lines = new ArrayList<>(); | ||
| lines.add("# Ticker,Name,Price"); | ||
| /** | ||
| * Saves stocks to a CSV file. | ||
| * The file includes a header comment line followed by one stock per line. | ||
| * | ||
| * @param filename the path to the CSV file to write | ||
| * @param stocks the list of stocks to save | ||
| * @throws IOException if the file cannot be written | ||
| */ | ||
| public void saveStocksToFile(String filename, List<Stock> stocks) throws IOException { | ||
| List<String> lines = new ArrayList<>(); | ||
| lines.add("# Ticker,Name,Price"); | ||
|
|
||
| lines.addAll(stocks.stream() | ||
| .map(stock -> String.format("%s,%s,%s", | ||
| stock.getSymbol(), | ||
| stock.getCompany(), | ||
| stock.getSalesPrice().toString())) | ||
| .toList()); | ||
| lines.addAll(stocks.stream() | ||
| .map(stock -> String.format("%s,%s,%s", | ||
| stock.getSymbol(), | ||
| stock.getCompany(), | ||
| stock.getSalesPrice().toString())) | ||
| .toList()); | ||
|
|
||
| Files.write(Paths.get(filename), lines); | ||
| } | ||
| Files.write(Paths.get(filename), lines); | ||
| } | ||
| } |
Oops, something went wrong.