Giter Club home page Giter Club logo

Comments (8)

CLEMENTJOHNSHAJI avatar CLEMENTJOHNSHAJI commented on May 29, 2024 1

Thanks for confirming. Can I contribute to this issue?

from text-fighter.

hhaslam11 avatar hhaslam11 commented on May 29, 2024

@CLEMENTJOHNSHAJI of course, contributions are welcome and appreciated 😄

from text-fighter.

BrendonButler avatar BrendonButler commented on May 29, 2024

Running Java 8 1.8.0_181 I could not replicate this issue. I thought it may have something to do with the Scanner Infinite Loop issue, but it just worked for me.

I only tested by cutting out the getValidInt() method from the Ui class and the do-while loop from the Casino class.

The int validator and loop seem to work fine. Maybe it has something to do with when it breaks out of the loop from the return statement? Not sure, I tried to help though haha!

from text-fighter.

hhaslam11 avatar hhaslam11 commented on May 29, 2024

It might simply just be the Ui.pause() call after the prompt causing an error extra stop in the program.
I cant test this at the moment though, as im not at my computer

from text-fighter.

CLEMENTJOHNSHAJI avatar CLEMENTJOHNSHAJI commented on May 29, 2024

Yes, you are right. I fixed the issue by converting pause() function in Action.java
from
public static void pause(){
try{
Scanner pauseScan = new Scanner(System.in);
String temp = pauseScan.nextLine();
Ui.println(temp);
}catch (Exception e){
//Blank for a reason - Not supposed to do anything.
}
}

to

public static void pause(){
try{
Scanner pauseScan = new Scanner(System.in);
return;
}catch (Exception e){
//Blank for a reason - Not supposed to do anything.
}
}

from text-fighter.

hhaslam11 avatar hhaslam11 commented on May 29, 2024

Doing that just makes the entire pause function essentially do nothing, making it not work at all (which you'll notice in other places the function is used. For example, when you attack an enemy, it won't pause the screen for the user to read the text before going back to the menu.

The problem is that the Ui.pause call shouldnt be there at all. So, in Casino.java, change

if (bet > Coins.get()) {
   Ui.cls();
   bet = 0;
   Ui.println("You do not have enough coins. Please enter a smaller amount. (Or enter 0 to go back)");
   Ui.pause();
}

to

if (bet > Coins.get()) {
   Ui.cls();
   bet = 0;
   Ui.println("You do not have enough coins. Please enter a smaller amount. (Or enter 0 to go back)");
}

Hopefully that makes sense

from text-fighter.

CLEMENTJOHNSHAJI avatar CLEMENTJOHNSHAJI commented on May 29, 2024

Yes. On working on this, I realized the use of pause() function in other places and did the same change you have suggested in casino.java.

from text-fighter.

CLEMENTJOHNSHAJI avatar CLEMENTJOHNSHAJI commented on May 29, 2024

I am a beginner, and I am working on this project as part of my coursework. I have to update my contributions in git for the completion of my course. So it would be of great help if you can merge my request.

from text-fighter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.