#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)

ocean yoke
#

hlllo

fierce sundial
ocean yoke
#

hi

#

ok

#

where do u use the method?

ocean yoke
fierce sundial
ocean yoke
#

oh

fierce sundial
ocean yoke
#

ok

fierce sundial
#

how would i create brackets around the output if yk?

#

like this

ocean yoke
#

i think so u are doing quetion wrong

#

can u put quetion here? with full file code given

#

u are making array every time

fierce sundial
#

sure

#

this is the question

#

theres a prequel before...but i gave up

fierce sundial
ocean yoke
#

can u paste the code one sec

#

i can explain u

fierce sundial
#

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;
    

}``
ocean yoke
#

all maybe

fierce sundial
#

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

ocean yoke
#

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?

fierce sundial
#

this assignment is just so hard

ocean yoke
#

i just added thing + "]" when array started and ended

fierce sundial
#

omgg

#

it works!!

#

thank u

#

im a bit concerned cuz the first part has a gap but ill try to figure it

ocean yoke
#

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?

fierce sundial
#

one sec ill code it rn!!

#

omg

#

GOD BLESS U

#

seriously i would love a tutor for java

#

you seem very knowledgable

ocean yoke
#

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

fierce sundial
#

😭 bruhhhh

ocean yoke
#

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

fierce sundial
#

i really overcomplicated it i totally didnt know

fierce sundial
#

thank u so much..

fierce sundial
#

btw are you familiar with getters @ocean yoke im still confused on a question

ocean yoke
#

yes lol i am

fierce sundial
ocean yoke
#

nah

fierce sundial
#

yeah they really are

ocean yoke
#

its just i made many things iwth java

#

if u do u would be more smart too

fierce sundial
#

i just feel like the toString i did is not what the question asks

#

so basically i deep coppied right

fierce sundial
#

fuck the assignment i have done is officially all wrong

#

skdfjksldjg

fierce sundial
fierce sundial
#

furious joined a day ago and hes already a master at it

ocean yoke
# fierce sundial what things have u made??

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

fierce sundial
#

bruh

#

bro

#

u basically finished the game and are now doing the sidequests

ocean yoke
#

#1020064092196716614

#

there is nn clasifying hand writen

fierce sundial
#

nice i saw

#

is eclipse the best java ide?

#

thats crazy lmfao

fierce sundial
#

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👀

ocean yoke
#

i am not much good there are much more good ones

fierce sundial
#

so humble ❤️

ocean yoke
#

ahhhhh

fierce sundial
ocean yoke
fierce sundial
#

loll

ocean yoke
#

lol

#

i am guy

fierce sundial
#

we know

ocean yoke
#

do u know how to make html

fierce sundial
#

no

#

a little bit

#

i know python

#

but i only know data analysis on python

ocean yoke
#

i am wokring on nn classyifying hand written digits website one

fierce sundial
#

can u also make useful plugins for people like @fierce sundial and me

#

maybe make a better swing

ocean yoke
#

you have underestimated swing its really vast thing

#

there are 100 pages book in it

fierce sundial
#

@ocean yoke are u still available to help

ocean yoke
fierce sundial
ocean yoke
#

oh then its ok i didnt know

#

yes but there is a prameter u dont need to ?

fierce sundial
#

yeah honestly im not sure cuz previous steps are so confusing

#

no like

ocean yoke
fierce sundial
#

i think we arent allowed to declare maze inside?

#

inside the toString

#

idk how to test the junits to see

ocean yoke
#

u dont need to to declare anything

#

nor do u need to add parameter

fierce sundial
#

ohh so its fine?

ocean yoke
#

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

fierce sundial
#

i did it here?

#

sure

ocean yoke
#

see objects are like it can be multiple

fierce sundial
#

thats that

ocean yoke
#

its correct what error is coming?

#

the to string can access the field

fierce sundial
#

really

#

someone on the other thread said u cant do that so i was doubting

#

do you think the setUp code is correct?

ocean yoke
#

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

fierce sundial
#

ohh

#

okay

#

thank u

fierce sundial
ocean yoke
#

why did u make thing array in maze constructer??

fierce sundial
#

😭 i changed the name from dogMaze to thing, i changed it

#

like changeed it bac

ocean yoke
#

there is a object variable u are assigning it new maze

fierce sundial
#

understood

#

okay

ocean yoke
#

is this some website?

fierce sundial
#

its eclipse

#

i mean

#

its a homework i am doing

ocean yoke
#

from where u got comments

fierce sundial
#

professors

#

on what we should add

ocean yoke
#

u are just makinga local variable

fierce sundial
#

sorry i didnt know, thank u

ocean yoke
#

remove full dogmaze code

#

i mean waht u are assigning local variable

#

remove the block

fierce sundial
#

sorry the whole matrix?

#

where else would i declare that

ocean yoke
#

paste here code of maze contructor then remove all code from the contructer

fierce sundial
#
     * 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

ocean yoke
#

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

fierce sundial
#

😭 its a school assignment

#

it has to be hard cuz she gives a deadline

fierce sundial
#

so i assume we need to put that in welp

#

sorry its so blurry

ocean yoke
#

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];
}
}

ocean yoke
#

lol nice i also wish i had somehting like this

fierce sundial
#

a few days, sunday

fierce sundial
ocean yoke
#

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

fierce sundial
#

so the first part was just for fun lmfao

ocean yoke
ocean yoke
#

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

ocean yoke
#

where the thread will star

#

main method

ocean yoke
#

where is public static void main???

fierce sundial
#

oh they dont have it

#

we have to use junit tests

#

i tried doing static void main it wouldnt work

ocean yoke
#

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

fierce sundial
#

they should have added SOME units of testing

#

oh um

#

i think i did the getter correctly

#

so now its task4

ocean yoke
#

just comment the mazecode which u wrote by hand that one

fierce sundial
#

which has srecursion

fierce sundial
ocean yoke
#

wow

#

they are complex idk why

fierce sundial
#

yup..

ocean yoke
#

they should learn first local variable and stuffs

fierce sundial
#

🤣 ikr

ocean yoke
#

do some simple projects urself

fierce sundial
#

or maybe i wasnt paying attention

fierce sundial
ocean yoke
#

ok do another thing

#

what are more u have to do fast

fierce sundial
ocean yoke
#

i have done somehting similar

#

i was makign paint fill angortihm

#

u know fill right it will fill with the given color

fierce sundial
#

yes i get it

ocean yoke
#

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

fierce sundial
ocean yoke
#

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

fierce sundial
#

alright yeahh

fierce sundial
ocean yoke
#
#

just read this everything u will understand much

#

this is theory u willl also have to actually make code once u learn

fierce sundial
#

😭 true

#

im in 2nd year and i rlly cant grasp the concepts at al

#

its like im getting thrown shit i dont wanna learn

ocean yoke
#

then u should have choosen somehting in which u fun

fierce sundial
#

my parents would beat me up if i chose something fun

fierce sundial
ocean yoke