English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories
0

How would you write a new class for a fish that always moves forward, unless that space is not empty. If it is not empty, it changes direction.

2007-04-26 07:53:17 · 2 answers · asked by John B 1 in Computers & Internet Programming & Design

2 answers

The class would be the fish.
It would have a variable to hold the direction that the fish is swimming in and there would be a method to change the direction.
Because this is a class it cannot have a method that detects what is in front of the fish. This is because the class has not been instantiated yet. This detection must therefore be outside of the class.

2007-04-26 08:29:38 · answer #1 · answered by AnalProgrammer 7 · 0 0

presize your question

2007-04-26 08:01:02 · answer #2 · answered by Anonymous · 0 0

fedest.com, questions and answers