arrow-left

All pages
gitbookPowered by GitBook
1 of 1

Loading...

0.2. Quiz

Quiz 0: Getting Started

hashtag
Coding

Right-click on the src/main/javaarrow-up-right directory under the project and create the package edu.emory.cs.utilsarrow-up-right. Right-click on the utils package and create the Java class Utilsarrow-up-right:

  • Add Utils.java to git.

  • Add the following methods to the Utils class:

Run the program by clicking [Run -> Run]. If you see 5 on the output pane, your program runs successfully.

hashtag
Testing

Open and add the following configurations (if not already), which would allow you to perform :

Right-click on the directory under the project and create the package . Right-click on the utils package and create the Java class :

  • Add UtilsTest.java to Git.

  • Add the following method to the UtilsTest class. Make sure to include all imports:

Run the test by clicking [Run -> Run]. If you see the test passed, your unit test runs successfully.

hashtag
Submission

  1. Add the instructors as collaborators in your GitHub repository:

  • Jinho Choi: jdchoi77

  • Peilin Wu: qualidea1217

  • Jeongrok Yu: jeongrok

2. Commit and push the following to your GitHub repository:

3. Submit the URL of your GitHub repository to Canvas.

Zinc Zhao: ZincZhao

  • build.gradlearrow-up-right
    JUnit Testingarrow-up-right
    src/test/javaarrow-up-right
    edu.emory.cs.utilsarrow-up-right
    UtilsTestarrow-up-right
    gradle/wrapper/gradle-wrapper.jararrow-up-right
    gradle/wrapper/gradle-wrapper.propertiesarrow-up-right
    .gitignorearrow-up-right
    static public int getMiddleIndex(int beginIndex, int endIndex) {
        return beginIndex + (endIndex - beginIndex) / 2;
    }
    
    static public void main(String[] args) {
        System.out.println(getMiddleIndex(0, 10));
    }
    test {
        useJUnitPlatform()
    }
    
    dependencies {
        testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
        testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.2'
    }
    package edu.emory.cs.utils;
    
    import org.junit.jupiter.api.Test;
    import static org.junit.jupiter.api.Assertions.assertEquals;
    
    @Test
    public void getMiddleIndexTest() {
        assertEquals(5, Utils.getMiddleIndex(0, 10));
    }
    build.gradlearrow-up-right
    gradlewarrow-up-right
    gradlew.batarrow-up-right
    settings.gradlearrow-up-right
    src/main/java/edu/emory/cs/utils/Utils.javaarrow-up-right
    src/test/java/edu/emory/cs/utils/UtilsTest.javaarrow-up-right