Skip to content

Commit 816d6e2

Browse files
Merge branch 'main' of https://github.com/CSC207-2022F-UofT/course-project-team-bbq into Anthony's_Branch
� Conflicts: � src/data/FlashcardSets.csv � src/data/Flashcards.csv
2 parents 93dd0a5 + c3fbe69 commit 816d6e2

File tree

4 files changed

+11
-26
lines changed

4 files changed

+11
-26
lines changed

src/data/FlashcardSets.csv

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
title,description,isPrivate,flashcardSetId,ownerUsername,flashcardIds
2-
test set 1,for testing study use case,false,0,testUser,0,1,2,3
3-
empty test set,for testing study use case with empty set,true,1,testUser
4-
Long Test Set,Insert Generic Description,false,2,Anthony,10,11,12,13,14,15,16,17,18,19,20,21
5-
CSC207 Final Exam Prep,Prepare for the CSC207 final exam with this flashcard set.,false,3,csc207,22,23,24,25,26,27,28,29,30,31,32,33,34,35
2+
"test set 1","for testing study use case",false,0,testUser,0,1,2,3
3+
"empty test set","for testing study use case with empty set",true,1,testUser
4+
"Long Test Set","Insert Generic Description",false,2,Anthony,10,11,12,13,14,15,16,17,18,19,20,21

src/data/Flashcards.csv

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,3 @@ Term I,Definition I,2022-11-13T15:32:29.666982800,18,2
1515
Term J,Definition J,2022-11-13T15:32:29.666982800,19,2
1616
Same Term,Same Definition,2022-11-13T15:32:29.666982800,20,2
1717
Same Term,Same Definition,2022-11-13T15:32:29.666982800,21,2
18-
Entity,A basic bit of data that we are storing in our program.,2022-12-03T21:52:27.507373800,22,3
19-
Factory,An object that knows how to make a class instance typically by calling a constructor.,2022-12-03T21:52:47.933762600,23,3
20-
Use case,Something a user wants to do with the program.,2022-12-03T21:53:04.556680900,24,3
21-
Input boundary,The public interface for calling the use case.,2022-12-03T21:53:17.541271200,25,3
22-
Interactor,The class that runs the use case (a subclass of the input boundary).,2022-12-03T21:53:34.172732200,26,3
23-
Repository,The persistence mechanism (a subclass of the gateway).,2022-12-03T21:53:49.101677400,27,3
24-
Gateway,The methods the repository needs to implement for the interactor to do its job.,2022-12-03T21:54:03.276713900,28,3
25-
Controller,The object that the UI asks to run a use case.,2022-12-03T21:54:14.308815800,29,3
26-
Presenter,The object that tells the UI what to do when a use case finishes.,2022-12-03T21:54:26.957394100,30,3
27-
Downcasting,Casting the type of a variable into its subclass.,2022-12-03T21:55:06.381100300,31,3
28-
Upcasting,Casting the type of a variable into its superclass.,2022-12-03T21:55:16.940754800,32,3
29-
Private,Can only be accessed by code within the same class.,2022-12-03T21:55:28.372671100,33,3
30-
Protected,Can only be accessed by code within the same class or within a class derived from the original.,2022-12-03T21:55:42.829787700,34,3
31-
Variable shadowing,The same variable name is used in two different scopes.,2022-12-03T21:56:00.916802500,35,3

src/main/java/frameworks_and_drivers/database/FlashcardDataAccess.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ public FlashcardDataAccess(String csvPath) throws IOException {
3737

3838
String row;
3939
while ((row = reader.readLine()) != null) {
40-
String[] col = row.split(",");
41-
String term = String.valueOf(col[headers.get("term")]);
42-
String definition = String.valueOf(col[headers.get("definition")]);
40+
String[] col = row.split(",(?=([^\"]|\"[^\"]*\")*$)");
41+
String term = String.valueOf(col[headers.get("term")]).replace("\"","");
42+
String definition = String.valueOf(col[headers.get("definition")]).replace("\"","");
4343
String creationDateText = String.valueOf(col[headers.get("creationDate")]);
4444
LocalDateTime creationDate = LocalDateTime.parse(creationDateText);
4545
int flashcardId = Integer.parseInt(col[headers.get("flashcardId")]);
@@ -64,7 +64,7 @@ private void save() {
6464

6565
for (FlashcardDsRequestModel set : flashcards.values()) {
6666
String line = String.
67-
format("%s,%s,%s,%s,%s", set.getTerm(), set.getDefinition(), set.getCreationDate(), set.getFlashcardId(),
67+
format("\"%s\",\"%s\",%s,%s,%s", set.getTerm(), set.getDefinition(), set.getCreationDate(), set.getFlashcardId(),
6868
set.getBelongsToId());
6969

7070
writer.write(line);

src/main/java/frameworks_and_drivers/database/FlashcardSetDataAccess.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ public FlashcardSetDataAccess(String csvPath) throws IOException {
3838

3939
String row;
4040
while ((row = reader.readLine()) != null) {
41-
String[] col = row.split(",");
42-
String title = String.valueOf(col[headers.get("title")]);
43-
String description = String.valueOf(col[headers.get("description")]);
41+
String[] col = row.split(",(?=([^\"]|\"[^\"]*\")*$)");
42+
String title = String.valueOf(col[headers.get("title")]).replace("\"","");
43+
String description = String.valueOf(col[headers.get("description")]).replace("\"","");
4444
boolean privacy = Boolean.parseBoolean(col[headers.get("isPrivate")]);
4545
int id = Integer.parseInt(col[headers.get("flashcardSetId")]);
4646
String ownerUsername = String.valueOf(col[headers.get("ownerUsername")]);
@@ -69,7 +69,7 @@ private void save() {
6969

7070
for (FlashcardSetDsRequestModel set : flashcardSets.values()) {
7171
StringBuilder line = new StringBuilder(String.
72-
format("%s,%s,%s,%s,%s", set.getTitle(), set.getDescription(), set.getIsPrivate(),
72+
format("\"%s\",\"%s\",%s,%s,%s", set.getTitle(), set.getDescription(), set.getIsPrivate(),
7373
set.getFlashcardSetId(), set.getOwnerUsername()));
7474
for(int flashcardIds : set.getFlashcardIds()){
7575
line.append(",");

0 commit comments

Comments
 (0)