Skip to content
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

Project stuck at Level 2 on Codecrunch but runs fine till Level 7 #581

Open
nowknowing opened this issue Nov 30, 2020 · 9 comments
Open
Labels
🖱️ Java General Questions with regards to Java or its API

Comments

@nowknowing
Copy link

Description

Hi, my project runs fine on jshell for all levels.
For level 2 I javac all my neccessary files,
and it all works fine, but on CodeCrunch it fails to find my ArriveEvent class.
Might it be due to Cyclic dependency in my methods that string from ArriveEvent?

All my non Main class are packaged in the same cs2030.simulator

Topic:

Screenshots (if any):

image
image

@nowknowing nowknowing added the 🖱️ Java General Questions with regards to Java or its API label Nov 30, 2020
@itmeruoxin
Copy link

can check if your parent Event class used "instanceof" any subclass? :) happened to me when i added instanceof RestEvent!

@nowknowing
Copy link
Author

No I dont use any instanceof in the parent Event class.
The parent class Event is clean.

Just that my each extending event(Arrive, Serve, done etc)
upon calling .execute()
calls the next event so they are cyclic.
In particular because Done.execute() makes new ServeEvent in certain cases.
and ServerEvent.execute() gives a Done() event.

@frisciliasultan
Copy link

I'm guessing DoneEvent and ServeEvent depend on each other. Happened to me before, my jshell worked but codecrunch was stuck at level 2. It was solved when the cyclic dependencies were resolved. Hope you can find the cyclic dependency and it should be fine after that! :)

@nowknowing
Copy link
Author

OH no
yes I am able to find the cyclic dependency but it'd mean big changes if it weren't allowed.
So this happens because cyclic dependency is banned here?

@itmeruoxin
Copy link

yea, prof banned cyclic dependency on codecrunch
maybe can try to throw the Done -> Serve transition into your simulation class? all the best!

@Mavvvvv
Copy link

Mavvvvv commented Nov 30, 2020

This is because code crunch specifically checks for cyclic dependencies and will flag it out. The cyclic dependency is probably because execute() of DoneEvent returns serveEvent and execute of serveEvent returns DoneEvent.
I had this same problem previously and how I go about this issue is to make my execute() of DoneEvent to return null and write the DoneEvent.execute() logic in Main.

@nowknowing
Copy link
Author

Oh yes thank you vm, I managed to just pluck out my function into my driver class.

but now it has stopped on level 3 since the input is different. Must we create a Main method for each level? HOw does it work?

@nowknowing
Copy link
Author

Ok i guess i can vary with input

@itmeruoxin
Copy link

yep can check length of args

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🖱️ Java General Questions with regards to Java or its API
Projects
None yet
Development

No branches or pull requests

4 participants