How Can I Integrate Two Fortran Programs for a Game of Hangman?

  • Fortran
  • Thread starter w3390
  • Start date
  • Tags
    Fortran
In summary, the programmer is attempting to create a program that will allow the user to play a game of hangman, and is having difficulty combining two separate programs.
  • #1
w3390
346
0
Hello all,

I am attempting to make a fortran program that allows the user to play a game of hangman. So far I have written a complete program that assembles piece by piece the base, gallows, rope, body parts, etc.. I have another completely separate program that reads from a file 264 random 8-letter words. The user inputs a number that corresponds to the word on that line in the file and the program slowly reveals the word as letters are guessed. Initially I have the word show up as eight stars (********). As the user guesses correctly, the appropriate letters are revealed.

The part I am having trouble with is combining these two programs to work in tandem. I have been told that I should be using two subroutines, where one of the subroutines is the program that develops the picture and the other subroutine is used to analyze the players letter guess and only call the first subroutine if the users guess is incorrect.

My biggest issue is not knowing how to reference one of the subroutines without the CALL statement going through all the picture code or all of the word code.

Any help on how to integrate these two programs would be greatly appreciated.
 
Technology news on Phys.org
  • #2
w3390 said:
Hello all,

I am attempting to make a fortran program that allows the user to play a game of hangman. So far I have written a complete program that assembles piece by piece the base, gallows, rope, body parts, etc.. I have another completely separate program that reads from a file 264 random 8-letter words. The user inputs a number that corresponds to the word on that line in the file and the program slowly reveals the word as letters are guessed. Initially I have the word show up as eight stars (********). As the user guesses correctly, the appropriate letters are revealed.

The part I am having trouble with is combining these two programs to work in tandem. I have been told that I should be using two subroutines, where one of the subroutines is the program that develops the picture and the other subroutine is used to analyze the players letter guess and only call the first subroutine if the users guess is incorrect.

My biggest issue is not knowing how to reference one of the subroutines without the CALL statement going through all the picture code or all of the word code.

Any help on how to integrate these two programs would be greatly appreciated.

If I understand it right, then I think you will have to go through both subroutines.
In fortran90 there is a mask which is used for array and vector functions.
Maybe you could apply a mask to known or unknown letters.
 

Related to How Can I Integrate Two Fortran Programs for a Game of Hangman?

What is Fortran?

Fortran is a high-level programming language commonly used in scientific and engineering applications. It was developed in the 1950s and is designed for numerical and scientific computing.

How do you play Hangman in Fortran?

To play Hangman in Fortran, you first need to write a program that generates a random word from a list of words. Then, the player inputs guesses for letters in the word until they guess the entire word correctly or run out of guesses.

Why would someone want to play Hangman in Fortran?

Playing Hangman in Fortran can be a fun way for programmers to practice their coding skills. It also allows them to apply their knowledge of loops, conditionals, and string manipulation in a practical way.

What are the advantages of using Fortran for Hangman?

Fortran is a powerful programming language for scientific computing, making it well-suited for handling the logic and calculations involved in a game like Hangman. It also has a simple syntax and is easy to learn, making it a good language for beginners.

Are there any limitations to playing Hangman in Fortran?

Like any programming language, Fortran has its limitations. It may not be the best choice for creating complex graphical interfaces or for creating games with advanced graphics. However, it is still possible to create a functional and enjoyable game of Hangman in Fortran.

Similar threads

  • Programming and Computer Science
Replies
8
Views
1K
  • Programming and Computer Science
Replies
4
Views
640
  • Programming and Computer Science
Replies
14
Views
2K
  • Programming and Computer Science
2
Replies
59
Views
9K
  • Programming and Computer Science
Replies
8
Views
3K
  • Programming and Computer Science
Replies
16
Views
1K
  • Programming and Computer Science
Replies
4
Views
2K
  • Programming and Computer Science
Replies
2
Views
2K
  • Programming and Computer Science
Replies
1
Views
577
  • Programming and Computer Science
Replies
2
Views
1K
Back
Top