Skip to content
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# This is a test comment

# Pull Requests

There is no contribution agreement in place, so we are not accepting external pull requests at this time.
Expand Down
97 changes: 92 additions & 5 deletions caseStudy/services/src/main/java/pojo/Company.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,97 @@
* Look at resources/data/companyInfo.json
*/
public class Company {
private String symbol;
private String name;
private String headquartersCity;
private String headquartersStateOrCountry;
private int numberOfEmployees;
private String sector;
private String industry;
private Stock[] stocks;

// TODO - Think back to your modelling session
// Define the attributes of a Company based on the
// provided data in resources/data
public Company(String symbol, String name, String headquartersCity, String headquartersStateOrCountry, int numberOfEmployees, String sector, String industry, Stock[] stocks) {
this.symbol = symbol;
this.name = name;
this.headquartersCity = headquartersCity;
this.headquartersStateOrCountry = headquartersStateOrCountry;
this.numberOfEmployees = numberOfEmployees;
this.sector = sector;
this.industry = industry;
this.stocks = stocks;
}

//GETTERS
public String getSymbol() {
return symbol;
}

// TODO - add getter and setter methods for your attributes
}
public String getName() {
return name;
}

public String getHeadquartersCity() {
return headquartersCity;
}

public String getHeadquartersStateOrCountry() {
return headquartersStateOrCountry;
}

public int getNumberOfEmployees() {
return numberOfEmployees;
}

public String getSector() {
return sector;
}

public String getIndustry() {
return industry;
}

public Stock[] getStocks() {
return stocks;
}

//SETTERS
public String setSymbol(String symbol) {
this.symbol = symbol;
return symbol;
}

public String setName(String name) {
this.name = name;
return name;
}

public String setHeadquartersCity(String headquartersCity) {
this.headquartersCity = headquartersCity;
return headquartersCity;
}

public String setHeadquartersStateOrCountry(String headquartersStateOrCountry) {
this.headquartersStateOrCountry = headquartersStateOrCountry;
return headquartersStateOrCountry;
}

public int setNumberOfEmployees(int numberOfEmployees) {
this.numberOfEmployees = numberOfEmployees;
return numberOfEmployees;
}

public String setSector(String sector) {
this.sector = sector;
return sector;
}

public String setIndustry(String industry) {
this.industry = industry;
return industry;
}

public Stock[] setStocks(Stock[] stocks) {
this.stocks = stocks;
return stocks;
}
}
75 changes: 71 additions & 4 deletions caseStudy/services/src/main/java/pojo/Stock.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,83 @@
*/

package pojo;
import java.util.Calendar;
import java.util.Comparator;

/**
* This class will define a company's end-of-day stock price
* Look at resources/data/historicalStockData.json
*/
public class Stock {

// TODO - Think back to your modelling session
// Define the attributes of a stock price based on the
// provided data in resources/data
/** Private variables */
private Calendar date;
private double price;

// TODO - add getter and setter methods for your attributes
/**Default constructor */
public Stock(){
date = GregorianCalendar.getInstance();
date.clear();
price = 0;
}

/**Constructor
* @param d date string to be parsed
* @param p price to be stored
*/
public Stock(String d, String p){
//splits date string into month, date, and year
String dateAttributes[] = d.split("\\");
//Iniatialize Calendar object and clear it
date = GregorianCalendar.getInstance();
date.clear();
//Parse string into integers
int year = Integer.parseInt(dateAttributes[2]);
int month = Integer.parseInt(dateAttributes[0]);
int day = Integer.parseInt(dateAttributes[1]);
//Put attributes into Calendar object
//Using month-1 because months in Calendar are 0-based
date.set(year, month-1, day);

price = p;

}

/** Getter method for price
* @return String price variable
*/
public String getPrice(){
return price;
}

/** Getter method for start date
* @return String start date variable in String form
*/
public Calendar getDate(){
return date;
}

/**Setter method for name
* @return String new name
*/
public String setName(String newName){
name = newName;
return name;
}

/**Setter method for date
* @return String new date
*/
public String setEnd(Calendar newDate){
date = newDate;
return date;
}

/**
* Comparator method
*/
@Override
public int compare(Stock s) {
return date.compareTo(s.getDate());
}
}
Loading