Jump to content

I have a programming professor that would like us to write a Tic Tac Toe game a specific way. He wants us to have the "board" class and have specific mutators within to deal with the data and keep as much info in that class as possible. Specifically, He would like us to have a few methods where the only variable passed is an integer that has to do with the location of a variable. for example:

public char getMarkAt(int location) //would return the mark at the given location.

Would I be able to have an instantiation of my jframe within this class, and have another class which handled all other work? For example: Have a jframe which was simply my nine boxes and a character array (let's say charArray for simplicity) full of a random character (We'll say 0 for the time being) and then get and set marks from the class by creating an instance of the class JFrame1 (named Picture) doing something like

JFrame1 Picture = new JFrame1;    
Picture.charArray[location] = 'X';

Or do I have this all wrong? I have been using JFrames as my main class in the past, and he has thrown in these mandatory passed variables to (I believe) keep us from doing so. Sorry for the craziness!

*_*_*_*_*_*_*Personal Rig*_*_*_*_*_*_*

CPU: Core i7 7700k @ 5.1 GHz

GPU: EVGA GTX 1070 SSC ACX 3.0

MOBO: ASROCK Z270 Killer SLI/AC

RAM: 16 GB HyperX Fury

COOLER: NZXT Kraken X52

CASE: NZXT S340 Elite

STORAGE:  500GB NVME Samsung 960 Pro

500GB Samsung 860 EVO

4TB Seagate Barracuda (7200 RPM)

OS: Windows 10 Pro

 

Link to comment
https://linustechtips.com/topic/737319-tic-tac-toe-program-questions/
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×