Skip to content

Primary/lesson 16 #540

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

Closed
wants to merge 4 commits into from
Closed
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
@@ -0,0 +1,50 @@
package com.codedifferently.lesson16;

import java.util.ArrayList;

public class Family {
private ArrayList<Integer> ages;
private ArrayList<Integer> divisions;

public Family() {
ages = new ArrayList<>();
divisions = new ArrayList<>();
}

public void addPerson(int id, int division, String name, int age) {
ages.add(age);
divisions.add(division);
}

public boolean hasA12YO() {
// TODO Auto-generated method stub
for (int age : ages) {
if (age == 12) {
return true;
}
}
return false;
}

public boolean hasADivThree() {
for (int division : divisions) {
if (division == 3) {
return true;
}
}
return false;
}

public int agesSizeValue() {
return ages.size();
}

public boolean hasSixKids() {
// TODO Auto-generated method stub
int num = ages.size();

return num < 6;
}

// throw new UnsupportedOperationException("Unimplemented method 'hasA12YO'");
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package com.codedifferently.lesson16;

import static org.junit.jupiter.api.Assertions.assertEquals;

import org.junit.jupiter.api.Test;

public class FamilyTest {

@Test
void testFamily_isOver12YO() {
// Arrange
var family = new Family();
family.addPerson(2, 1, "Chase Blue", 12);

// Act
boolean hasA12YO = family.hasA12YO();

// Assert
assertEquals(true, hasA12YO);
}

@Test
void testFamily_hasDivThree() {
// Arrange
var family = new Family();
family.addPerson(5, 3, "Brysen Thompson", 4);

// Act
boolean hasADivThree = family.hasADivThree();

// Assert
assertEquals(true, hasADivThree);
}

@Test
// has SixKids
void testFamiy_hasSixKids() {
// int i = 0;

var family = new Family();

// Arrange
family.addPerson(1, 1, "Paige Blue", 15);
family.addPerson(6, 3, "Carter Thompson", 1);
family.addPerson(3, 2, "Abigal Thompson", 10);
family.addPerson(4, 2, "Christian Thompson", 9);

// Act
// boolean addPerson(id) == 6;

// Assert
assertEquals(true, family.hasSixKids());
}
}