diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/News.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/News.java
index 8eb8d75..6a4d46f 100644
--- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/News.java
+++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/News.java
@@ -4,15 +4,34 @@
import java.util.List;
import java.util.Random;
+/**
+ * Represents generated news related to a company and its market trend.
+ *
+ *
This class creates random news headlines and authors based on whether the
+ * company has a positive or negative trend.
+ */
public class News {
private final String company;
private final int trend;
private final Random random = new Random();
- public News(String company, int trend){
+
+ /**
+ * Constructs a News object for a given company and trend.
+ *
+ * @param company the company the news is related to
+ * @param trend a numeric indicator of market trend (positive = good news, negative = bad news)
+ */
+ public News(String company, int trend) {
this.company = company;
this.trend = trend;
}
- public String generateAuthor(){
+
+ /**
+ * Generates a random author email for the news article.
+ *
+ * @return a randomly selected fictional author email
+ */
+ public String generateAuthor() {
List authors = new ArrayList<>();
authors.add("market@stocks.com");
authors.add("myfatherworksatmicrosoft@hotmail.com");
@@ -36,34 +55,67 @@ public String generateAuthor(){
authors.add("nsa.definitely.not.reading.this@nsa.gov");
return authors.get(random.nextInt(authors.size()));
}
- public String generateNews(){
+
+ /**
+ * Generates a random news headline based on the company's trend.
+ *
+ * If the trend is positive, good news headlines are generated.
+ * If the trend is negative or zero, bad news headlines are generated.
+ *
+ * @return a randomly generated news headline
+ */
+ public String generateNews() {
if (trend > 0) {
- List goodNews = new ArrayList<>();
- goodNews.add("Turns out the product of " + company + " is good for the environment.");
- goodNews.add("Beaver population increased due to the efforts of " + company + ".");
- goodNews.add("Eminem dropped new hit single, namedropping " + company + ".");
- goodNews.add("Founder of " + company + " seen feeding the homeless.");
- goodNews.add(company + " got frontpage in new forbes magazine, on top companies to invest in.");
- goodNews.add("IShowSpeed seen using " + company + " products in the background of viral livestream.");
- goodNews.add("New studies show that " + company + " took part in inventing the rainbow back in 4,542,997,974 BC");
- goodNews.add(company + " has made breakthroughs in the field of artificial intelligence.");
- goodNews.add("After the release of the brand new logo of " + company + ", the logo has been called the \"a glimpse of the future\".");
- goodNews.add("EX-EMPLOYEES of " + company + " REVEAL that the work environment and safety regulations are not up to basic standards but far surpassing them.");
- goodNews.add("Founder of " + company + " seen rudely pushing a homeless man out of the road, saving his life.");
+ List goodNews = getStringsGood();
+
return goodNews.get(random.nextInt(goodNews.size()));
}
+ List badNews = getStringsBad();
+ return badNews.get(random.nextInt(badNews.size()));
+ }
+
+ private List getStringsGood() {
+ List goodNews = new ArrayList<>();
+ goodNews.add("Turns out the product of " + company + " is good for the environment.");
+ goodNews.add("Beaver population increased due to the efforts of " + company + ".");
+ goodNews.add("Eminem dropped new hit single, namedropping " + company + ".");
+ goodNews.add("Founder of " + company + " seen feeding the homeless.");
+ goodNews.add(company + " got frontpage in new forbes magazine, "
+ + "on top companies to invest in.");
+ goodNews.add("IShowSpeed seen using " + company
+ + " products in the background of viral livestream.");
+ goodNews.add("New studies show that " + company
+ + " took part in inventing the rainbow back in 4,542,997,974 BC");
+ goodNews.add(company + " has made breakthroughs in the field of artificial intelligence.");
+ goodNews.add("After the release of the brand new logo of " + company
+ + ", the logo has been called the \"a glimpse of the future\".");
+ goodNews.add("EX-EMPLOYEES of " + company + " REVEAL that the work environment "
+ + "and safety regulations are not up to basic standards but far surpassing them.");
+ goodNews.add("Founder of " + company
+ + " seen rudely pushing a homeless man out of the road, saving his life.");
+ return goodNews;
+ }
+
+ private List getStringsBad() {
List badNews = new ArrayList<>();
badNews.add("Turns out the product of " + company + " is bad for the environment.");
badNews.add("Founder of " + company + " seen rudely pushing a homeless man out of the way.");
badNews.add(company + " mentioned in epstein files.");
- badNews.add(company + " has created many dams for beavers, causing them to lay around in the sun all day and die of laziness.");
- badNews.add(company + " initiated a campaign to feed the homeless with burgers, using dog meat. This has decreased the number of starvation deaths among the homeless.");
- badNews.add("Turns out " + company + " created the first covid-19 vaccines, which are not safe for humans.");
+ badNews.add(company + " has created many dams for beavers, causing them to lay"
+ + " around in the sun all day and die of laziness.");
+ badNews.add(company + " initiated a campaign to feed the homeless with burgers, using dog meat."
+ + "This has decreased the number of starvation deaths among the homeless.");
+ badNews.add("Turns out " + company + " created the first covid-19 vaccines, "
+ + "which are not safe for humans.");
badNews.add("Extensive research of " + company + " shows financial holes in the company.");
badNews.add("Founder of " + company + " heiling at press conference discussing great ideas.");
- badNews.add("EX-EMPLOYEES of " + company + " REVEAL that the work environment and safety regulations are not up to basic standards.");
- badNews.add("US-Army found using " + company + " issued weapons that malfunctioned causing mass civilian casualties.");
- badNews.add(company + " got frontpage in new forbes magazine, on top companies not to invest in.");
- return badNews.get(random.nextInt(badNews.size()));
+ badNews.add("EX-EMPLOYEES of " + company + " REVEAL that the work environment"
+ + " and safety regulations are not up to basic standards.");
+ badNews.add("US-Army found using " + company
+ + " issued weapons that malfunctioned causing mass civilian casualties.");
+ badNews.add(company + " got frontpage in new forbes magazine, "
+ + "on top companies not to invest in.");
+
+ return badNews;
}
}
diff --git a/src/test/java/edu/ntnu/idi/idatt2003/gruppe42/model/calculator/PurchaseCalculatorTest.java b/src/test/java/edu/ntnu/idi/idatt2003/gruppe42/model/calculator/PurchaseCalculatorTest.java
index 4bc34f8..a5ec387 100644
--- a/src/test/java/edu/ntnu/idi/idatt2003/gruppe42/model/calculator/PurchaseCalculatorTest.java
+++ b/src/test/java/edu/ntnu/idi/idatt2003/gruppe42/model/calculator/PurchaseCalculatorTest.java
@@ -9,6 +9,12 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+/**
+ * Unit tests for {@link PurchaseCalculator}.
+ *
+ * Verifies correct calculation of gross value, commission, tax, and total
+ * for a stock purchase transaction.
+ */
public class PurchaseCalculatorTest {
private PurchaseCalculator calculator;
diff --git a/src/test/java/edu/ntnu/idi/idatt2003/gruppe42/model/calculator/SaleCalculatorTest.java b/src/test/java/edu/ntnu/idi/idatt2003/gruppe42/model/calculator/SaleCalculatorTest.java
index b8ef938..1231d97 100644
--- a/src/test/java/edu/ntnu/idi/idatt2003/gruppe42/model/calculator/SaleCalculatorTest.java
+++ b/src/test/java/edu/ntnu/idi/idatt2003/gruppe42/model/calculator/SaleCalculatorTest.java
@@ -9,6 +9,12 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+/**
+ * Unit tests for {@link SaleCalculator}.
+ *
+ *
Verifies correct calculation of gross value, commission, tax, and total
+ * for a stock sale transaction.
+ */
public class SaleCalculatorTest {
private SaleCalculator calculator;
diff --git a/src/test/java/edu/ntnu/idi/idatt2003/gruppe42/model/transaction/TransactionArchiveTest.java b/src/test/java/edu/ntnu/idi/idatt2003/gruppe42/model/transaction/TransactionArchiveTest.java
index a02dea9..0d61c75 100644
--- a/src/test/java/edu/ntnu/idi/idatt2003/gruppe42/model/transaction/TransactionArchiveTest.java
+++ b/src/test/java/edu/ntnu/idi/idatt2003/gruppe42/model/transaction/TransactionArchiveTest.java
@@ -10,6 +10,12 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+/**
+ * Unit tests for {@link TransactionArchive}.
+ *
+ *
Verifies correct storage, filtering, and analysis of transactions
+ * including purchases and sales.
+ */
public class TransactionArchiveTest {
private TransactionArchive archive;
private Purchase purchase;