#for this get method, do i need to declare maze again and use a for loop to go through it?
1 messages · Page 1 of 1 (latest)
bruh i need help
store the maze outside of the constructer?
sorry i mean i kinda moved on from that also hi
oh
ok
i think so u are doing quetion wrong
can u put quetion here? with full file code given
u are making array every time
😭
all of the code?
or just toString
``@Override
public String toString() {
//insert your code here. Change the return value to fit your purpose.
String [][] dogMaze = {{"1110", "1010", "1010", "1000"}, {"1010", "1000", "1001", "0101"},{"1100", "0011", "0101", "0110"},{"0101", "1101", "0110", "1001"},
{"0110", "0011", "1110", "0010"}};
String thing = "";
for (int i = 0; i<dogMaze.length;i++) {
for (int j=0; j<dogMaze[i].length;j++) {
thing += " " + dogMaze[i][j];
}
thing += "\n";
}
return thing;
}``
all maybe
idk if i can send, maybe i can send u the whole file?
``public class PE1 {
Maze dogMaze;
/**
* This method sets up the maze using the given input argument
* @param maze is a maze that is used to construct the dogMaze
*/
public void setup(String[][] maze) {
/* insert your code here to create the dogMaze
* using the input argument.
*/
}``
i just really need help with the bracket stuff right now
public String toString() {
//insert your code here. Change the return value to fit your purpose.
String [][] dogMaze = {{"1110", "1010", "1010", "1000"}, {"1010", "1000", "1001", "0101"},{"1100", "0011", "0101", "0110"},{"0101", "1101", "0110", "1001"},
{"0110", "0011", "1110", "0010"}};
String thing = "";
for (int i = 0; i<dogMaze.length;i++) {
think+="[";
for (int j=0; j<dogMaze[i].length;j++) {
thing += " " + dogMaze[i][j];
}
think+="]";
thing += "\n";
}
return thing;
}
this works?
this assignment is just so hard
i just added thing + "]" when array started and ended
omgg
it works!!
thank u
im a bit concerned cuz the first part has a gap but ill try to figure it
for (int j=0; j<dogMaze[i].length;j++) {
thing += " " + dogMaze[i][j];
}
this loop is there rigt?
for (int j=0; j<dogMaze[i].length;j++) {
if(j==0){
thing += dogMaze[i][j];
}else {
thing += " " + dogMaze[i][j];
}
}
just add an if that if j == 0 then dont add space
@fierce sundial now it works?
one sec ill code it rn!!
omg
GOD BLESS U
seriously i would love a tutor for java
you seem very knowledgable
Arrays.deepToString(array).replace("], ", "]\n").replace(",", "").replace("[[", "[").replace("]]", "]")
no lol
u can use this
remove all lines of code
@Override
public String toString() {
return Arrays.deepToString(dogMaze).replace("], ", "]\n").replace(",", "").replace("[[", "[").replace("]]", "]");
}
this will work
just one one of code
@fierce sundial
😭 bruhhhh
arrays.deeptostring converts the array of more then 1 dimensinal to string
and then u can just replace the multiple array to nothing and add new lines
i really overcomplicated it i totally didnt know
ohhh okok
thank u so much..
btw are you familiar with getters @ocean yoke im still confused on a question
yes lol i am
this guy is very smart
nah
yeah they really are
i just feel like the toString i did is not what the question asks
so basically i deep coppied right
what things have u made??
fuck the assignment i have done is officially all wrong
skdfjksldjg
we both joined this server today lol
loll
furious joined a day ago and hes already a master at it
multiplayer game simple one, neural network recognizing hand written didgits(application), neural network locating squares and shapes, spammer which types random words(simple), paint application (took alot time), gif creator, plugins in minecraft prison plugin and a plugin which draws any image to blocks, currently making neural network recognizing hand written didgits(http), neural networks trianing with evolution algorithm good for training games and trying to make discord bot in java
ikr
furious should make a new programming language in java lol
🤣 FACTSS
he should make some plugins
maybe i can use them in my school assignments
what if its a girl👀
i am not much good there are much more good ones
so humble ❤️
ahhhhh
girls dont exist on the internet
who it ?
i called u a "he", so he is saying "what if u are a girl?"
loll
we know
do u know how to make html
💍
no
a little bit
i know python
but i only know data analysis on python
i am wokring on nn classyifying hand written digits website one
can u also make useful plugins for people like @fierce sundial and me
maybe make a better swing
@ocean yoke are u still available to help
yes say whatver
also toString cant take parameters, i have to use the previous method u told me right
see here
Maze dogMaze;
i think we arent allowed to declare maze inside?
inside the toString
idk how to test the junits to see
ohh so its fine?
u didnt make contrusctor correct
u have to actually store it lol
in outside variable
the constructor basically does nothing
can u send whole file
see objects are like it can be multiple
really
someone on the other thread said u cant do that so i was doubting
do you think the setUp code is correct?
i dont think u didnt did anything there
u are just initializing a local variable
do like this
this.dogMaze = new Maze(maze);
@fierce sundial
sorry what does this do, like dogMaze transfers its stuff to it, becomes the input parameter?
why did u make thing array in maze constructer??
new Maze calls the contrustor and this.lol just is same as lol unless u have local variable of same name understood?
there is a object variable u are assigning it new maze
what u are doing here is just making a local variable
is this some website?
from where u got comments
u are just makinga local variable
sorry i didnt know, thank u
remove full dogmaze code
i mean waht u are assigning local variable
remove the block
paste here code of maze contructor then remove all code from the contructer
* This constructor makes the maze.
* @param maze is a 2D array that contains information
* on how each cell of the array looks like.
*/
public Maze(String[][] maze) {
/*complete the constructor so that the maze is
* a deep copy of the input parameter.
*/
String [][] dogMaze = {{"1100", "1000", "1010", "1010","1001","1100","1000","1001","1100","1001"},
{"0101", "0110", "1010", "1001","0101","0101","0111","0101","0101","0101"},
{"0101", "0011", "0101", "0110"},
{"0101", "1101", "0110", "1001"},
{"0101", "0011", "1110", "0010"}};
for (int i = 0; i<dogMaze.length;i++) {
maze[i]= new String[dogMaze[i].length];
for (int j=0; j<dogMaze[i].length;j++) {
maze[i][j]=dogMaze[i][j];
}
}```
this is what i was doing
the 2d array is declared it writes
u dont have to make ur own string array of maze i think so u have to use the parameter right?
it will be wrong
why are u doing this try some other easy projects too first
u can do this but u should do some simple projects too and see how they work u will understand
she made us MAKE the maze in the beginning
so i assume we need to put that in welp
sorry its so blurry
public Maze(String[][] maze) {
this.maze= new String[maze.length][maze[0].length];
for (int i = 0; i<maze.length;i++) {
for (int j=0; j<maze[i].length;j++) {
this.maze[i][j]=maze[i][j];
}
}
how many days u got
lol nice i also wish i had somehting like this
a few days, sunday
☠️ lmfao
you can do this in half hour to one hour you will have to understand the quetion alos first but
it looks like u dont need to actually create the array
so the first part was just for fun lmfao
bruh
some changes i made is i actually assigned a new array to the null array or it will throw error if u access any feild then maze is the parameter and this.maze is the object field which i was talkign about because both name same u will have to use this.maze whwnever u want class object
are u sure the teacher gave u array and u have to make the array
u will gve the teacher with full errors lol ?? or u will test before
alot of error is going to come
can u show me where is main code
lol
okay this makes sense
where is public static void main???
oh they dont have it
we have to use junit tests
i tried doing static void main it wouldnt work
ok then i think u dont need to make the arra
they will input the array when making new object of pe1
ok now what u have to do
they should have added SOME units of testing
oh um
i think i did the getter correctly
so now its task4
just comment the mazecode which u wrote by hand that one
which has srecursion
okay sure
yup..
they should learn first local variable and stuffs
🤣 ikr
do some simple projects urself
or maybe i wasnt paying attention
this is 20% of my grade so i have to hustle, maybe another time😭
i have done somehting similar
i was makign paint fill angortihm
u know fill right it will fill with the given color
yes i get it
what i did i added to a list a pixel which is nearby it
nearby it and added it if the color was same as middle color
then a called it again on the same list so that everything in list gets near by points and gets added to list
like that
and u have to add a stop thing too in recursive otherwise stackoverflow
did u understand what u have to do ?
what does dog gate do
the dog has to find the 0s that are open doors and exit from there, like we need to do a recursion thing to help it
first thing how u have to solve this problem like just make it work or do it as teacher said if teacher is actually checking ur code
alright yeahh
u should send me this stuff seriously like tutorials
just read this everything u will understand much
this is theory u willl also have to actually make code once u learn
😭 true
im in 2nd year and i rlly cant grasp the concepts at al
its like im getting thrown shit i dont wanna learn
then u should have choosen somehting in which u fun
my parents would beat me up if i chose something fun
btw we have to declare the matrix otherwise it will be wrong
then ask ur teacher why the hell have u added parameter of the stringarray in constructer of pe1