Skip to content

Deep Nesting Solutions

Tstream edited this page Apr 26, 2017 · 1 revision

Deep Nesting Example 1 Solution:

public boolean do_stuff() {
    if (this_thing && and_this && also_this && aswell_this) {
        return true
    }
    return false               
}

Deep Nesting Example 2 Solution:

public int do_stuff() {
    if (this_thing && and_this && also_this && aswell_this) {
        return 1
    }
    if (this_thing && and_this && also_this && !aswell_this) {
        return 2
    }
    if (this_thing && and_this && !also_this) {
        return 3
    }
    if (this_thing && !and_this) {
        return 4
    }
    if (!this_thing) {
        return 5
    }             
}

Clone this wiki locally