#gui issue in java swing

1 messages Ā· Page 1 of 1 (latest)

jaunty peak
#

I cannot for the life of me make it accept id and pass instead of username and pass
the code is txt

safe caveBOT
#

<@&987246487241105418> please have a look, thanks.

safe caveBOT
pliant oyster
#

might help to mention where and what method as its not 'small' code

jaunty peak
pliant oyster
#

team work or gpt ?

jaunty peak
#

if u want the other classes i can post them

jaunty peak
#

i asked chatgpt and it barely made 50 lines of some nonsense

pliant oyster
#

got the account class aswell ?

jaunty peak
#

gimme a sec

safe caveBOT
#

Please use this format for posting code:

```java
// Example java program
int value = 5;
System.out.println(value);
```

Which results in:

// Example java program
int value = 5;
System.out.println(value);

For syntax highlighting, you have to add the name of the language after the three backticks, like ```java. Please make sure to use exactly this format, so no space between the backticks and the language name, and a newline before the code starts. If done right, the syntax highlighting will even be applied to your text as you type, before sending.

errant narwhal
#
public class Account {
    private String name;
    private int id;
    private int password;

    public Account(String name, int id, int password) {
        this.name = name;
        this.id = id;
        this.password = password;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getPassword() {
        return password;
    }

    public void setPassword(int password) {
        this.password = password;
    }

    @Override
    public String toString() {
        return name + " (ID: " + id + ")";
    }
}```
pliant oyster
#

well u got a getId so use that

jaunty peak
pliant oyster
#

account.getId(Integer.parseInt( ..... should do it , same as your password

jaunty peak
pliant oyster
#

get I d

#

not lowercase

jaunty peak
#

yeye my bad

errant narwhal
#

.equals(id) id isn't a variable

pliant oyster
#

now parse the text to int

jaunty peak
#

gimme a sec

pliant oyster
#

same as u did with the passwprd

jaunty peak
#

to try

whole light
#

Wait your password can only be a number?

jaunty peak
#

i asked him

errant narwhal
#

then maybe change the variable to passcode

jaunty peak
#

ye lol

pliant oyster
#

also 1 tiny thing u might want to reflect on. On your system, everyone has admin rights by default ?

#

normally its the inverse. Only a few get admin rights and the rest are normal users

jaunty peak
#

did i do it wrong?

pliant oyster
#

its a method, not a variable

#

and getId needs to change in username

jaunty peak
pliant oyster
#

your feeding in username, password

#

so either refactor those to match, or match the variables

jaunty peak
errant narwhal
whole light
#

You should also clean up your class a bit, there's a lot going in one class. It has a very strong openAI vibe.

pliant oyster
#

and if u seen exeptions, use them instead of return null

jaunty peak
#

ill try to clean up

pliant oyster
#

the lazy friend did do the effort to open a browser to generate some code šŸ˜‰

whole light
pliant oyster
#

pointers keep coming, line 172 on the gist ( for lab lab : labs ... ), servers no point

#

unless your filling all your labs with null, u do not need the check

#

( and not to mention its double but that might be a c&p error )

errant narwhal
#

Objects default to null if not initialized

pliant oyster
#

shoudlnt be in the collection then if its nothing

#

unless your doing 1 wacky assigment where u have to mix arrays and lists, refactor your code

whole light
#

I'd also reconsider the way you store your output, that's really not a convenient manner.

pliant oyster
#

(These are not points to put the code down, but to improve on your skills )

jaunty peak
pliant oyster
#

u can ask your friend to revise them šŸ™‚

jaunty peak
#

i genuinely dont get it whats wrong(bear in my mind this is on me as i volunteered for an extracurricular be4 even finishing java 200 course)

errant narwhal
#
SwingUtilities.invokeLater(new Runnable() {
    public void run() {
        new ReservationSystemGUI();
    }
});```
you can rewrite this as
```java
SwingUtilities.invokeLater(() -> new ReservationSystemGUI());
jaunty peak
#

any eror i ask him abt in his methods

pliant oyster
#

doesnt matter how he / she generated it

jaunty peak
#

he sends completely diff ones

errant narwhal
#

in fact you can't

jaunty peak
pliant oyster
#

dont try to go to fast

#

your guessing as bad as your teammate

#

your method has 2 variables, both STRING

#

so u need to check on your account.getId a parsed version of one of those strings

#

so its like K said. Your on the correct path, but u do not need to parse the Account's return type, only the variable coming from String type

#

so ( but in code ) account.getId() is equal to the converted text of id

jaunty peak
#

like this

#

oh my god

#

it worked

pliant oyster
#

check it a few times more to be certain, but in some cases that might work

jaunty peak
#

man the prof said the requirement is finishing java 201 & i havent finished 200 yet i shouldve probs listened to him

#

i need to train more and probably kick my teammate

pliant oyster
#

no need to kick

#

enlighten him / her , like Simon mentiond, its a shared responsabilty

#

both either fail or pass

errant narwhal
errant narwhal
#

ok

jaunty peak
#

thank u for telling me

jaunty peak
pliant oyster
#

also tell him, that u asked advice here and that everyone saw that the code was generated šŸ˜‰

#

so your prof will aswell

jaunty peak
#

also another friend said im stupid for not using netbeans' gui form designer and that i wasted time coding by hand

jaunty peak
pliant oyster
#

not stupid, but there is a point there. Code a gui by hand a few times. Then make life easier

jaunty peak
#

is that how most ppl do?

#

+did u try lua's love2d for GUIs?

pliant oyster
#

most people have migrated to javaFx and the answer will depend on what gui it has to be

#

couple simple popups, most likely by hand

#

anything that needs to look 'alright' and more , with editors as they are faster, easier to see what your doing ( remember the term WYSIWYG ? ) )

jaunty peak
#

thank u both @pliant oyster @errant narwhal i hope i didnt waste ur time by taking a proj i was suited for fully

pliant oyster
#

u didnt, and your doing it anyhow, so u ARE suited

errant narwhal
#

np, I was literally sitting in my chair waiting for things to help out with

jaunty peak
#

is there a way to display it visually or will i have to restructure it completely to be accepted by netbeans

pliant oyster
#

the inbuild netbeans editor use some sort of form to create it so from 0. U can however tie in your methods once its created

jaunty peak
#

ye ur right i need to clean up the code anyway

#

so y not