#TMC through VSC

1 messages · Page 1 of 1 (latest)

golden tulip
#

Just did part 5 exercise 11 and it is all good the code is right and used the test file to check it too, but for submitting it to tmc it takes forever.

public class Apartment {

    private int rooms;
    private int squares;
    private int princePerSquare;

    public Apartment(int rooms, int squares, int pricePerSquare) {
        this.rooms = rooms;
        this.squares = squares;
        this.princePerSquare = pricePerSquare;
    }

    public boolean largerThan(Apartment compared){
        if(this.rooms > compared.rooms){
            return true;
        }

        if(this.rooms < compared.rooms){
            return false;
        }

        if(this.squares > compared.squares){
            return true;
        }

        if(this.squares < compared.squares){
            return false;
        }

        if(this.princePerSquare > compared.princePerSquare){
            return true;
        }

        if(this.princePerSquare < compared.princePerSquare){
            return false;
        }
                                  
        return false;
    }

    public int priceDifference(Apartment compared){
        int a = this.squares * this.princePerSquare;
        int b = compared.squares * compared.princePerSquare;

        if(a > b){
            return a - b;
        } else {
            return b - a;
        }
    }

    public boolean moreExpensiveThan(Apartment compared){
        int a = this.squares * this.princePerSquare;
        int b = compared.squares * compared.princePerSquare;

        if(a > b){
            return true;
        } else {                                             
            return false;
        }
    }

}

could give reasons why this is happening

brazen gyroBOT
#

<@&987246399047479336> please have a look, thanks.

weak seal
#

Maybe all of the if statements?..

#
public boolean largerThan(Apartment compared){
    if(this.rooms > compared.rooms || this.squares > compared.squares || this.pricePerSquare > compared.pricePerSquare){
        return true;
    }
                              
    return false;
}
#

The other thing is that you named pricePerSquare as pri*n*cePerSqaure

golden tulip
#

nah

#

solved it

weak seal
#

Actually that should still work, I guess it depends on the site or software you're submitting to.

golden tulip
#

it was mooc requires jdk11

#

as it is old asf

weak seal
#

Ah.

golden tulip
#

so just went and installed it

#

yeah