forked from christianhujer/expensereport
-
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.
- Loading branch information
1 parent
4fe9593
commit 29ecc2f
Showing
70 changed files
with
12,994 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 @@ | ||
*.iml | ||
.idea/ |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
*.[adios] |
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,53 @@ | ||
#include <stdio.h> | ||
#include <time.h> | ||
|
||
enum Type { | ||
DINNER, | ||
BREAKFAST, | ||
CAR_RENTAL | ||
}; | ||
|
||
struct Expense { | ||
enum Type type; | ||
int amount; | ||
}; | ||
|
||
void printExpenses(struct Expense *expenses[], size_t numExpenses) { | ||
int total = 0; | ||
int mealExpenses = 0; | ||
|
||
time_t now; | ||
if (time(&now) == -1) | ||
return; | ||
|
||
printf("Expenses %s\n", ctime(&now)); | ||
|
||
for (size_t i = 0; i < numExpenses; i++) { | ||
struct Expense *expense = expenses[i]; | ||
|
||
if (expense->type == DINNER || expense->type == BREAKFAST) { | ||
mealExpenses += expense->amount; | ||
} | ||
|
||
char *expenseName; | ||
switch (expense->type) { | ||
case DINNER: | ||
expenseName = "Dinner"; | ||
break; | ||
case BREAKFAST: | ||
expenseName = "Breakfast"; | ||
break; | ||
case CAR_RENTAL: | ||
expenseName = "Car Rental"; | ||
break; | ||
} | ||
|
||
char *mealOverExpensesMarker = ((expense->type == DINNER && expense->amount > 5000) || (expense->type == BREAKFAST && expense->amount > 1000)) ? "X" : " "; | ||
|
||
printf("%s\t%d\t%s\n", expenseName, expense->amount, mealOverExpensesMarker); | ||
total += expense->amount; | ||
} | ||
|
||
printf("Meal expenses: %d\n", mealExpenses); | ||
printf("Total expenses: %d\n", total); | ||
} |
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 @@ | ||
CPPFLAGS:=-MMD | ||
CFLAGS:=-W -Wall -pedantic -Werror | ||
|
||
.PHONY: all | ||
all: ExpenseReport.o | ||
|
||
.PHONY: clean | ||
clean:: | ||
$(RM) *.[adios] | ||
|
||
-include *.d |
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 @@ | ||
# Expense Report C | ||
|
||
Kata for Coding Dojos. |
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 @@ | ||
bin/ | ||
obj/ | ||
/packages/ | ||
.idea |
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,22 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "expensereport-csharp", "expensereport-csharp\expensereport-csharp.csproj", "{4D670DD0-5E29-49CE-AFE9-F5C7ACDB89D0}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "expensereport-ut", "expensereport-ut\expensereport-ut.csproj", "{07C2B482-2F0F-4B66-9F09-9D9505C9466E}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{4D670DD0-5E29-49CE-AFE9-F5C7ACDB89D0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{4D670DD0-5E29-49CE-AFE9-F5C7ACDB89D0}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{4D670DD0-5E29-49CE-AFE9-F5C7ACDB89D0}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{4D670DD0-5E29-49CE-AFE9-F5C7ACDB89D0}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{07C2B482-2F0F-4B66-9F09-9D9505C9466E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{07C2B482-2F0F-4B66-9F09-9D9505C9466E}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{07C2B482-2F0F-4B66-9F09-9D9505C9466E}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{07C2B482-2F0F-4B66-9F09-9D9505C9466E}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
EndGlobal |
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,62 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace expensereport_csharp | ||
{ | ||
public enum ExpenseType | ||
{ | ||
DINNER, BREAKFAST, CAR_RENTAL | ||
} | ||
|
||
public class Expense | ||
{ | ||
public ExpenseType type; | ||
public int amount; | ||
} | ||
|
||
public class ExpenseReport | ||
{ | ||
public void PrintReport(List<Expense> expenses) | ||
{ | ||
int total = 0; | ||
int mealExpenses = 0; | ||
|
||
Console.WriteLine("Expenses " + DateTime.Now); | ||
|
||
foreach (Expense expense in expenses) | ||
{ | ||
if (expense.type == ExpenseType.DINNER || expense.type == ExpenseType.BREAKFAST) | ||
{ | ||
mealExpenses += expense.amount; | ||
} | ||
|
||
String expenseName = ""; | ||
switch (expense.type) | ||
{ | ||
case ExpenseType.DINNER: | ||
expenseName = "Dinner"; | ||
break; | ||
case ExpenseType.BREAKFAST: | ||
expenseName = "Breakfast"; | ||
break; | ||
case ExpenseType.CAR_RENTAL: | ||
expenseName = "Car Rental"; | ||
break; | ||
} | ||
|
||
String mealOverExpensesMarker = | ||
expense.type == ExpenseType.DINNER && expense.amount > 5000 || | ||
expense.type == ExpenseType.BREAKFAST && expense.amount > 1000 | ||
? "X" | ||
: " "; | ||
|
||
Console.WriteLine(expenseName + "\t" + expense.amount + "\t" + mealOverExpensesMarker); | ||
|
||
total += expense.amount; | ||
} | ||
|
||
Console.WriteLine("Meal expenses: " + mealExpenses); | ||
Console.WriteLine("Total expenses: " + total); | ||
} | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
expensereport-csharp/expensereport-csharp/expensereport-csharp.csproj
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 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netcoreapp2.2</TargetFramework> | ||
<RootNamespace>expensereport_csharp</RootNamespace> | ||
</PropertyGroup> | ||
|
||
</Project> |
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,18 @@ | ||
using NUnit.Framework; | ||
|
||
namespace Tests | ||
{ | ||
public class Tests | ||
{ | ||
[SetUp] | ||
public void Setup() | ||
{ | ||
} | ||
|
||
[Test] | ||
public void Test1() | ||
{ | ||
Assert.Pass(); | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
expensereport-csharp/expensereport-ut/expensereport-ut.csproj
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,15 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netcoreapp2.2</TargetFramework> | ||
|
||
<IsPackable>false</IsPackable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="nunit" Version="3.11.0"/> | ||
<PackageReference Include="NUnit3TestAdapter" Version="3.11.0"/> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0"/> | ||
</ItemGroup> | ||
|
||
</Project> |
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 @@ | ||
*.[adios] |
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,55 @@ | ||
#include <chrono> | ||
#include <iostream> | ||
#include <iterator> | ||
#include <list> | ||
|
||
using namespace std; | ||
|
||
enum Type | ||
{ | ||
BREAKFAST, DINNER, CAR_RENTAL | ||
}; | ||
|
||
class Expense | ||
{ | ||
public: | ||
Type type; | ||
int amount; | ||
}; | ||
|
||
void printReport(list<Expense> expenses) | ||
{ | ||
int total = 0; | ||
int mealExpenses = 0; | ||
|
||
auto now = chrono::system_clock::to_time_t(chrono::system_clock::now()); | ||
cout << "Expenses " << ctime(&now) << '\n'; | ||
|
||
for (list<Expense>::iterator expense = expenses.begin(); expense != expenses.end(); ++expense) { | ||
if (expense->type == BREAKFAST || expense->type == DINNER) { | ||
mealExpenses += expense->amount; | ||
} | ||
|
||
string expenseName = ""; | ||
switch (expense->type) { | ||
case DINNER: | ||
expenseName = "Dinner"; | ||
break; | ||
case BREAKFAST: | ||
expenseName = "Breakfast"; | ||
break; | ||
case CAR_RENTAL: | ||
expenseName = "Car Rental"; | ||
break; | ||
} | ||
|
||
string mealOverExpensesMarker = (expense->type == DINNER && expense->amount > 5000) || (expense->type == BREAKFAST && expense->amount > 1000) ? "X" : " "; | ||
|
||
cout << expenseName << '\t' << expense->amount << '\t' << mealOverExpensesMarker << '\n'; | ||
|
||
total += expense->amount; | ||
} | ||
|
||
cout << "Meal expenses: " << mealExpenses << '\n'; | ||
cout << "Total expenses: " << total << '\n'; | ||
} |
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 @@ | ||
CPPFLAGS:=-MMD | ||
CXXFLAGS:=-W -Wall -pedantic -Werror | ||
|
||
.PHONY: all | ||
all: ExpenseReport.o | ||
|
||
.PHONY: clean | ||
clean:: | ||
$(RM) *.[adios] | ||
|
||
-include *.d |
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 @@ | ||
# Expense Report C++ | ||
|
||
Kata for Coding Dojos. |
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 @@ | ||
.PHONY: all | ||
all: | ||
go build ./... |
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 @@ | ||
# Expense Report Go | ||
|
||
Kata for Coding Dojos. |
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,55 @@ | ||
package expenses | ||
|
||
import ( | ||
"fmt" | ||
"time" | ||
) | ||
|
||
type Type int | ||
|
||
const ( | ||
DINNER Type = iota + 1 | ||
BREAKFAST | ||
CAR_RENTAL | ||
) | ||
|
||
type Expense struct { | ||
Type Type | ||
Amount int | ||
} | ||
|
||
func printReport(expenses []Expense) { | ||
total := 0 | ||
mealExpenses := 0 | ||
|
||
fmt.Printf("Expenses %s\n", time.Now().Format("2006-01-02")) | ||
|
||
for _, expense := range expenses { | ||
if expense.Type == DINNER || expense.Type == BREAKFAST { | ||
mealExpenses += expense.Amount | ||
} | ||
|
||
var expenseName string | ||
switch (expense.Type) { | ||
case DINNER: | ||
expenseName = "Dinner" | ||
case BREAKFAST: | ||
expenseName = "Breakfast" | ||
case CAR_RENTAL: | ||
expenseName = "Car Rental" | ||
} | ||
|
||
var mealOverExpensesMarker string | ||
if expense.Type == DINNER && expense.Amount > 5000 || expense.Type == BREAKFAST && expense.Amount > 1000 { | ||
mealOverExpensesMarker = "X" | ||
} else { | ||
mealOverExpensesMarker = " " | ||
} | ||
|
||
fmt.Printf("%s\t%d\t%s\n", expenseName, expense.Amount, mealOverExpensesMarker) | ||
total += expense.Amount | ||
} | ||
|
||
fmt.Println("Meal expenses: %d\n", mealExpenses) | ||
fmt.Println("Total expenses: %d\n", total) | ||
} |
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,9 @@ | ||
# IntelliJ IDEA | ||
.idea | ||
*.iml | ||
|
||
# make | ||
.User.mk | ||
|
||
# Maven | ||
target/ |
Oops, something went wrong.