Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Help with Tic Tac Toe  RSS feed

 
Djavida Avac
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys.

So I got a big task, to complete the game tictactoe. Guys I added 3 file to this message:

First one (CellState+CellLocation+.....java) contains 6 java classes (sorry that these are all in 1 file...) - so I got this tictactoe task and I got these 6 java classes for this task, and I got a 'readme...' file too...I also added this file (readme_for_the_game_....). Please check these all please please! Readme file too, it's very important! And finally I added a 'YourConsultant' file too which is created by me, this is my solution for the task...there is an other 'YourConsultant' class also as you see in the first 6 java classes but this is just the original 'YourConsultant' class without solution.

So guys, I would need if somebody could read and get properly what is the task and then check my solution in YourConsultant.java and then let me know I am right with my solution or not? If not, what is the problem with my solution? If am I right it's not needed any console, any GUI, just to finish the class 'YourConsultant' which has to implement the 'Consultant' interface, and then we can check our work with the 'ConsultantTest' class which is also int "the first 6 java class" so in the first added file - but yeah my problem is that I can't understand properly this test class yet ....and one more important thing: I know that my 'YourConsultant' class solution isn't right properly yet (I think..), because if I try to compile, it will not okay properly.... 2 things which don't okay I think:
- to copy enum values into an ArrayList (at my case I wanted for example to copy 'CellLocation' values into the 'arrayCellLocationX' and 'arrayCellLocationO' ArrayLists, but couldn't properly...how can I do it?).
- to exchange an enum class's values to an other enum class's values (sorry if my English not perfect, I am not An English man in NewYork - hahaha). So at my case this is the code-line in the 'playGame' method where is my "enum-exchange" attempt:
cellLocation = cellState;  ----> I know it's not okay (or okay?), but then how can I do this?

Please help me guys, I would be the happiest guy on the planet if I could to complete this. Please help me.

Thanks!!!

:-)


 
Djavida Avac
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No idea why I couldn't added the files....shit....I tried it many times but nothing happened... :,( why?
 
Djavida Avac
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay guys I added the file to my GoogleDrive, here is the link where you can reach them (sorry if the order of the files aren't the some like I wrote above in the text):

https://drive.google.com/drive/folders/0B2Gj-4vpUGu5bTEtSWl5aEVJYkE?usp=sharing

Thanks again for your help!
 
Djavida Avac
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

II. This is the README file - very important

The goal of this exercise is for you to create an implementation of the
Consultant interface. You can use the provided class YourConsultant that needs
to be finished. We will run your solution against our unit tests. The source
and unit tests for this project may be found in the zip file associated with
this file.

Please read the JavaDoc carefully.

Keep in mind that:

* We are only interested in an implementation for the Consultant interface. We
  do not, for instance, want an application that can interact with other
  (human) players. We do not expect any kind of GUI, nor do we expect a class
  with a main method.

* We are not so much looking for a solution that performs very fast. If your
  implementation finds the best solution within a second, that is good enough.

* We are interested in the readability of your code.

* Follow the instructions carefully, but keep it simple! Your solution might of
  course require more files (Java types), be careful however not to
  over-engineer your solution.

* You are not allowed to change existing code, i.e. do not change existing
  files.
 
Djavida Avac
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Djavida Avac wrote:
Djavida Avac wrote:
Djavida Avac wrote:

I. This is the "6 java class"  together


(CellState class)




(CellLocation class)




(GameBoard class)




(Consultant class)




(YourConsultant class)




(ConsultantTest class)


 
Djavida Avac
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

III. And at least my 'YourConsultant' class, as my solution...sorry to everyody for my horrible lots of 'replies' which are really horrible and .....can't write down....I am totally new here, don't know yet how things works...

 
Norm Radder
Ranch Foreman
Posts: 2240
28
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How does one compile and execute the code for testing?  I don't see a main() method.
 
Djavida Avac
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Norm Radder wrote:How does one compile and execute the code for testing?  I don't see a main() method.


No idea. Good question.
 
Henry Wong
author
Sheriff
Posts: 23283
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Djavida Avac wrote:
Norm Radder wrote:How does one compile and execute the code for testing?  I don't see a main() method.


No idea. Good question.


If you don't know how to compile or run your code, how do you know it even works?  And to follow that, how do you develop that large wad of code without even compiling the code?

Henry
 
Djavida Avac
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Henry Wong wrote:

If you don't know how to compile or run your code, how do you know it even works?  And to follow that, how do you develop that large wad of code without even compiling the code?

Henry


I know how to compile and run. Yeah at this case really didn't figure out these yet...but actually I can compile my code and got 2 errors (not so much isn't it?) - to compile code it's not needed to have main() method, it's needed just for run. But mainly I wanna to know is my solution okay or totally a "wrong way"?

Thanks for your reply and for your time buddy! And thanks for you Norm Radder too.
 
Norm Radder
Ranch Foreman
Posts: 2240
28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
wanna to know is my solution okay

One of the ways to determine that is to execute the code and see if it does what you want.

One thing that looks wrong is the repeated if statements from lines 241 to 336.  Any time there is that  much repeated code there must be a way to write a loop or a method to reduce it.

Also the repeated code from 98 to 171 looks like it could be reduced to a a few lines that get data from an array or collection of some type.
 
Tobias Bachert
Ranch Hand
Posts: 85
18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm afraid that you have to start over:
The JavaDoc of consulant states, that the implementation should be immutable
Most of your methods don't operate on the passed parameters but on instance variables, e.g. the strategy methods (and thus the suggest method too) ignore the state of the provided board
(There are a bit more than 2 compile errors (but mostly typos))
 
Piet Souris
Rancher
Posts: 1979
67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmm, what is an 'immutable implementation', I wonder? Is that something opposed to some implementation that changes on the flight?

A possible serious error is in line 205 (numberOfX).

However, my biggest worry is in the requirement that the Consultant class is to be checked for its readability. Is that code easily readable? Is it, as Tobias mentiones, clear that all these instance variables are soly based on the most recent GameBoard?
 
Djavida Avac
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tobias Bachert wrote:I'm afraid that you have to start over:
The JavaDoc of consulant states, that the implementation should be immutable

What means basicly 'immutable implementation' ? I thought it means just that from class what I write (YourConsultant) we can't make any instance...but yeah it's maybe not okay because the 'ConsultantTest' class will create new YourConsultant() class.. I am confused..
Can somebody somehow help 1-2 code-correction as I could see what you mean guys? Really just 1-2 code line, if it can take more understandable what you mean (for me).
Thank you all! I appreciate your time and help on this.
 
Knute Snortum
Sheriff
Posts: 4073
112
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry to everyody for my horrible lots of 'replies' which are really horrible and .....can't write down....I am totally new here, don't know yet how things works... 

A really good habit is to press the Preview button in your relies before you press Submit.  This gives you the chance to edit your message before posting.
 
Knute Snortum
Sheriff
Posts: 4073
112
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From the README:

The goal of this exercise is for you to create an implementation of the
Consultant interface. You can use the provided class YourConsultant that needs
to be finished. We will run your solution against our unit tests. The source
and unit tests for this project may be found in the zip file associated with
this file.


So I'm assuming you have added code only to the YourConsultant file and you're asking how well does it implement Consultant. I would suggest simply compiling YourConsultant and a lot of errors will present themselves.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!