Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DylanBlanchardAssignment1 #25

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,18 @@ public ClassRepo() {

public Section findById(String id) {
// TODO: find a section by its id
return null;
for(int i = 0; i < sections.size(); i++)
{
if(sections.get(i).getId() == id)
{
return sections.get(i);
}
}
return null;
}

public void addSection(Section section) {
// TODO: add a section to the repository
sections.add(section);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.kevinthorley.csi280.project01;

import java.util.List;
import java.util.ArrayList;

public class ClassRepo {

private List<Section> sections;

public ClassRepo() {
this.sections = new ArrayList<Section>();

this.sections.add(new Section("csi-280-51", "Open Source Software Development", "2016SP"));
this.sections.add(new Section("csi-280-52", "Open Source Software Development", "2016SP"));
}

public Section findById(String id) {
// TODO: find a section by its id
for(int i = 0; i < sections.size(); i++)
{
if(sections.get(i).getId() == id)
{
return sections.get(i);
}
}
return null;
}

public void addSection(Section section) {
// TODO: add a section to the repository
sections.add(new Section(section.getId(), section.getName(), section.getSemester()));
}
}