Author: Malignant Manor
Date: 01-01-11 01:51
The one major difference between the first two is how they collapse in Notepad++.
Example 1 collapses every else statement with the first if and it will look like this:
if (current_day == 0) {
}
The Example 2 only collapses the first if block and it will look like this:
if (current_day == 0) {
else if (current_day == 1) {
if ((hour == 23) && (minute >= 58)) {
randomPartyBark("@Day 2.@");
game_current = (game_current + addDayTwo);
}
}
else if (current_day == 2) {
if ((hour == 23) && (minute >= 58)) {
game_current = (game_current + addDayThree);
randomPartyBark("@Day 3.@");
}
}
else if (current_day == 3) {
if ((hour == 23) && (minute >= 58)) {
game_current = (game_current + addDayFour);
randomPartyBark("@Day 4.@");
}
}
else if (current_day == 4) {
if ((hour == 23) && (minute >= 58)) {
randomPartyBark("@Day 5.@");
game_current = (game_current + addDayFive);
}
}
else if (current_day == 5) {
if ((hour == 23) && (minute >= 58)) {
randomPartyBark("@Day 6.@");
game_current = (game_current + addDaySix);
}
}
else if (current_day == 6) {
if ((hour == 23) && (minute >= 58)) {
randomPartyBark("@Day 0.@");
game_current = (game_current - minusSix);
}
}
}
You could then collapse each individual else (second example)
if (current_day == 0) {
else if (current_day == 1) {
else if (current_day == 2) {
else if (current_day == 3) {
else if (current_day == 4) {
else if (current_day == 5) {
else if (current_day == 6) {
or any combination (Example 2)
if (current_day == 0) {
if ((hour == 23) && (minute >= 58)) {
randomPartyBark("@Day 1.@");
game_current = (game_start + addDayOne);
}
}
else if (current_day == 1) {
else if (current_day == 2) {
else if (current_day == 3) {
if ((hour == 23) && (minute >= 58)) {
game_current = (game_current + addDayFour);
randomPartyBark("@Day 4.@");
}
}
else if (current_day == 4) {
else if (current_day == 5) {
else if (current_day == 6) {
Examples 3 and 4 collapse similar to Example 2
Example 3
if (current_day == 0)
{
else if (current_day == 1)
{
else if (current_day == 2)
{
else if (current_day == 3)
{
if ((hour == 23) && (minute >= 58))
{
game_current = (game_current + addDayFour);
randomPartyBark("@Day 4.@");
}
}
else if (current_day == 4)
{
else if (current_day == 5)
{
else if (current_day == 6)
{
}
Example 4
if (current_day == 0)
{
else if (current_day == 1)
{
else if (current_day == 2)
{
else if (current_day == 3)
{
if ((hour == 23) && (minute >= 58))
{
game_current = (game_current + addDayFour);
randomPartyBark("@Day 4.@");
}
}
else if (current_day == 4)
{
else if (current_day == 5)
{
else if (current_day == 6)
{
}