#little help with project

1 messages · Page 1 of 1 (latest)

modern kernel
#

One message removed from a suspended account.

restive shoalBOT
#

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

modern kernel
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

wise ice
#

Get the reference to the user associated with the request from memory and pass that into thr constructor. Need more context though if u want clearer suggestions

modern kernel
#

One message removed from a suspended account.

#

One message removed from a suspended account.

wise ice
#

that would be a decent idea for the CLI

modern kernel
#

One message removed from a suspended account.

#

One message removed from a suspended account.

wise ice
#

well and another option would be to have a currently logged in user then each request made from there is under that user until they sign out and back in to a different user

modern kernel
#

One message removed from a suspended account.

wise ice
#

unless u have some requirement that each time a request is made then a user is selected during the request, not before

modern kernel
#

One message removed from a suspended account.

wise ice
#

having a persisted login you mean? Or per request

#

(it wont make a huge difference either way)

modern kernel
#

One message removed from a suspended account.

#

One message removed from a suspended account.

wise ice
#

wdym cant

modern kernel
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

wise ice
restive shoalBOT
# wise ice .java has syntax highlighting

Looks like you attempted to use a command? Please note that we only use slash-commands on this server 🙂

Try starting your message with a forward-slash / and Discord should open a popup showing you all available commands.
A command might then look like /foo 👍

modern kernel
#

One message removed from a suspended account.

wise ice
#

so a gui complicates things a little more than a CLI in some regards, but both login systems would work in either case

modern kernel
#

One message removed from a suspended account.

wise ice
#

in either case you're going to have to perform a user search and store that user (whether u use a hashmap or not)

#

You could, Map<Integer, User> or whatever the key on user is

#

but you could also do a for loop to find them

#

if this is for a class thats picky then probably just use a forloop

#

unless they dont care what code you use, then a hashmap is technically better

modern kernel
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

wise ice
#

the map wouldnt be part of a user or manifestation

#

the user list could be a hashmap i suppose yeah

#

but the User object itself wouldnt

#

do u understand how maps work?

modern kernel
#

One message removed from a suspended account.

#

One message removed from a suspended account.

modern kernel
wise ice
#

this for example would be better as a hashmap fyi

#

oh wait does the JOptionPane API expect that

modern kernel
#

One message removed from a suspended account.

#

One message removed from a suspended account.

wise ice
#

oh it kinda makes sense

modern kernel
#

One message removed from a suspended account.

#

One message removed from a suspended account.

wise ice
#

yeah

#

is java ur first language, or do u have any experience with others?

modern kernel
#

One message removed from a suspended account.

#

One message removed from a suspended account.

wise ice
#

ok. Well a map is a "key-value" pair. Keys are something unique, values are something that doesnt necessarily need to be unique

modern kernel
#

One message removed from a suspended account.

wise ice
#

so a userID might be unique, and that "key" would link to the value of the User

#

Map<User, Manifesto> would indicate that a user can only ever have 1 manifesto

modern kernel
#

One message removed from a suspended account.

wise ice
#

no, it would likely be a String or an Integer/Long

#

does your user have an ID?

modern kernel
#

One message removed from a suspended account.

wise ice
#

do you have something like

public class User {
  private int id;
  private String firstName;
  private String lastName;
}``` for example
modern kernel
#

One message removed from a suspended account.

#

One message removed from a suspended account.

wise ice
#

whats cpf mean

modern kernel
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

wise ice
#

ok yeah then that would be the ID for them

#

so you could have Map<String, Usuario>

#

Why is that an abstract class?

modern kernel
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

wise ice
#

ok that makes sense yeah

modern kernel
#

One message removed from a suspended account.

wise ice
#

im guessing options are different per user type

modern kernel
#

One message removed from a suspended account.

#

One message removed from a suspended account.

wise ice
#

so each user can perform the same tasks within the program

modern kernel
#

One message removed from a suspended account.

wise ice
#

ok

#

would it make sense for a user to make consecutive requests?

#

then you wouldnt need to have the user ID for each request type

modern kernel
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

wise ice
#

You're saying you believe the code is more complicated by doing?

#

If you want to keep it with user ID per request thats fine since they all have access to the same requests

#

(You wouldnt want them to start filling out a request and then not have access to it)

modern kernel
wise ice
#

do you know how to write static methods?

#

well actually static is kinda trash

modern kernel
wise ice
#

basically so you dont have 8 levels of nested control flow I would make each form its own method at least

modern kernel
#

One message removed from a suspended account.

wise ice
#

well the dialog boxes

#

but like you could roughly simplify it down here

#

theres more but then its at least readable

modern kernel
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

wise ice
#

just make a class for managing the flow

modern kernel
#

One message removed from a suspended account.

wise ice
#

(easier said than done haha) yeah

modern kernel
#

One message removed from a suspended account.

wise ice
#

I would just call it Controller (or whatever that translates to)

#

its a fairly standard name

#

heres a simple template with the variables you had before ```java
public class Controller {
private List<Manifestacao> manifestacaoList;
private List<Usuario> usuarioList;

public Controller() {
    manifestacaoList = new ArrayList<>();
    usuarioList = new ArrayList<>();
}

}```

#

then you can create a public void run() method that does basically why main(String[] args) did before, but without the variable declarations in it

modern kernel
#

One message removed from a suspended account.

wise ice
#

then each switch case can be a method

modern kernel
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

wise ice
#

yeah but the controller can call them themselves

#

so main would just do controller.run();

#

its just a way of getting out of static context

#

and then every method in the class will have access to private List<Manifestacao> manifestacaoList; private List<Usuario> usuarioList;

modern kernel
#

One message removed from a suspended account.

#

One message removed from a suspended account.

wise ice
#

well the key would be String (the type of cpf) and the value would be Usuario not manifests

#

you're wanting to map user IDs to users

modern kernel
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

wise ice
#

either you have a shared list of all manifests, or each user could maintain their own list of manifests

#

based on ur original post the manifest had a User object in it. you could do that and just keep the list of manifestos as u have and it'd be fine

modern kernel
#

One message removed from a suspended account.

wise ice
#

it doesnt need a map for storing manifests

#

if you had a map it would have to be Map<UserKey, List<Manifest>>, which is not great

modern kernel
#

One message removed from a suspended account.

wise ice
#

its whoever wrote it

#

it would be like having a book with an author

#

just replac book with manifest and author with user

modern kernel
wise ice
#

its just not necesary to have that complexity since the manifest already has the user. If you want to filter a users manifests you could just iterate across the List<Manifest> and find matching users

modern kernel
#

One message removed from a suspended account.

wise ice
#

are you able to add the List<Manifest> to the Usario class?

modern kernel
#

One message removed from a suspended account.

wise ice
#

basically chop off the map part and just directly store each uses manifests on their instance

#

so a user would have their ID, name, birthday, and manifests

modern kernel
#

One message removed from a suspended account.

#

One message removed from a suspended account.

wise ice
#

ok, so they have an empty list

#

meaning they have no manifests at the time a user is created

modern kernel
#

One message removed from a suspended account.

wise ice
#

yeah. user.addManifest(newManifest)

#

then that method can just add to the list, and perhaps establish the bi-directional link from manifest to user

modern kernel
#

One message removed from a suspended account.

wise ice
#

yeah like this one java Manifestacao manifestacao = new Manifestacao(); manifestacao.setDataManifestacao(dateFormat); manifestacao.setDescricao(descricaoInput.getText());

modern kernel
#

One message removed from a suspended account.

wise ice
#

and at this point you'd be able to remove the shared manifest list

#

or keep it

#

but if u keep the list you'll have to maintain it

#

meaning you would have to add the manifest to the user, and also add it to the shared controller list

#

unless u need all manifestos for all users often

modern kernel
#

One message removed from a suspended account.

wise ice
#
public class Controller {
    private List<Manifestacao> manifestacaoList;```
#

the previously local variables

modern kernel
#

One message removed from a suspended account.

#

One message removed from a suspended account.

wise ice
#

it would be a List/ArrayList

modern kernel
#

One message removed from a suspended account.

wise ice
#

a user has multiple manifests, so instead of private Manifest manifest it would be a private List<Manifest> manifests. (and then = new ArrayList<>() )

modern kernel
#

One message removed from a suspended account.

wise ice
#

also your variables should start with lowercase letters

#

yes

#

each user will have its own array

#

also a tip, you had manifestacaoArray.size() == 0. There is a method for this. manifestacaoArray.isEmpty()

modern kernel
#

One message removed from a suspended account.

#

One message removed from a suspended account.

wise ice
#

it is

modern kernel
#

One message removed from a suspended account.

wise ice
#

You can either maintain the list in the controller, or have a method that iterates over the users and adds them to a combined list

List<Manifest> allManifests = new ArrayList<>();
for (User u : users) {
  allManifests.addAll(u.getManifests());
}
return allManifests;
#

technically maintaining the list directly is better performance, but for this it doesnt matter

#

and then you can change it later if you want

#

but just get the 'easy' version of it working

#

because if you add and remove manifests from a user you also would need to remove it from the shared list, but by recreating the shared list everytime it is needed it'll always be correct

modern kernel
#

One message removed from a suspended account.

#

One message removed from a suspended account.

wise ice
#

not too complex. it would just be

private List<Manifest> getAllManifests() {
  List<Manifest> allManifests = new ArrayList<>();
  for (User u : users) {
    allManifests.addAll(u.getManifests());
  }
  return allManifests;
}```
#

then anytime you need all the manifests just call that method

modern kernel
#

One message removed from a suspended account.

wise ice
#

i'll be back in a little bit but just have a controller with one variable (the list of users) and go from there. (Since users have the manifests)

#

~15 min

modern kernel
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

nimble anchor
#

the user interacts with the view, all interactions gets forwarded to the controller

#

the controller interacts with the model, determines if any view changes need to be made

#

hence the term "controller". it is the controller

wise ice
#

its not a true controller since its technically not listening for any events, but its executing branches based on user inputs

#

i guess maybe thats not even a criteria for it, but either way it doesnt matter too much on the specific terminology

modern kernel
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

wise ice
#

one main change to try and make is split this

#

into more like this

wise ice
#

static should only* be used for things that dont depend on any state

#

e.g. Math.abs(-1) == 1

#

static method, doesnt depend on state, only inputs

#

and since all methods of a class have access to that classes variables, you can have the program's state scoped to a smaller size

#

your main file will just be ```java
public class Main {
public static void main(String[] args) {
Controller controller = new Controller();
controller.run();
}
}

modern kernel
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

wise ice
#

yeah, its just a way of getting us away from static

modern kernel
#

One message removed from a suspended account.

#

One message removed from a suspended account.

wise ice
#

also, you currently have java int menuInput = 0; while (menuInput != 2) { // get menu input switch (menuInput) { ... } }
a way to make this simpler to understand is using while (true). java while (true) { int menuInput = // get input if (menuInput == 2) { break; // Exit while true } switch (menuInput) { ... } }

wise ice
#

roughly like ```java
class Controller {
private List<Manifest> manifestacaoList;
private List<User> usuarioList;

public Controller() {
    manifestacaoList = new ArrayList<>();
    usuarioList = new ArrayList<>();
}

public static void main(String[] args) {
    Controller controller = new Controller();
    controller.run();
}

public void run() {```
#

but its best practice that main is, well, main

#

just a pure entry point

#

Also they're usingSystem.exit(0); which isn't recommended to terminate when you have other ways

wise ice
modern kernel
#

One message removed from a suspended account.

wise ice
#

correct, this is the part i was mentioning about maintaining a shared list in addition to each users' list

#

Leaving it out for now and just having a getter method handle the combining will be a simpler start

modern kernel
#

One message removed from a suspended account.

wise ice
#

yes that was the idea, but just leave it out for now and get the list the other way

modern kernel
#

One message removed from a suspended account.

wise ice
#

and revisit it at the end if you wish, it wouldnt be a large change, just not something to be concerned about

#

Wdym "all"

modern kernel
#

One message removed from a suspended account.

#

One message removed from a suspended account.

wise ice
#

Just like User is your abstract class to the 3 types available, List can be thought of as being very similar, and ArrayList is a specific type of List. You can type everything as ArrayList<> as you want but its not necessary. Its better practice for the declared type to be List, and less to type

#

you would still say private List<User> usarioList = new ArrayList<>(); though

#

you can't say new List<>() with a few asterisks**

modern kernel
#

One message removed from a suspended account.

wise ice
#

The difference isnt super important to understand right now. Also just forget about the Map<userid, user> for now, and just make it a method that iterates over the users. Can change that easily later on

#

An arraylist is a list but not all lists are arraylist

modern kernel
#

One message removed from a suspended account.

wise ice
#

i would hope the instructor for this wouldnt care if List<> __ = new ArrayList<>() is used, since it literally is an arraylist

#

but if you want to be safe, just say ArrayList<> ... = new ArrayList<>()

#

it makes practically no difference here

#

in large applications its better to use the supertype so you dont have to specifically be a subtype

#

like how some of your methods will take in a User and not a Professor

#

like if the method applies to all users, it shouldnt be subtyped, but i'm off track

#

also the reason i changed it from userArray to userList in the name is because userArray implies User[] as the type

#

(arraylist is a list that uses arrays [] internally)

#

so in terms of a template, you should have ```java
public class Main {
public static void main(String[] args) {
Controller controller = new Controller();
controller.run();
}
}

And ```java
public class Controller {
    private ArrayList<User> userList = new ArrayList<>();

    public Controller() {}

    public void run() {
         // TODO!
    }
}```
modern kernel
#

One message removed from a suspended account.

wise ice
#

not really

#

theres some copy pasting you can do with ur old switch cases

#

but they'll just be like 50 line methods instead of a 200 lines method

modern kernel
#

One message removed from a suspended account.

wise ice
#

cause rn you only have a few paths covered and its hundreds of lines, and very hard to tell whats happening

modern kernel
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

wise ice
#

this part is within run

#

so at a super high level with no implementations: ```java
public void run() {
int userInput = 1;
switch (userInput) {
case 1 -> part1();
case 2 -> part2();
case 3 -> part3();
}
}

private void part1() {

}

private void part2() {

}

private void part3() {

}```
#

rename them to something different, but thats the idea

#

(thats java 14+ switch syntax btw)

modern kernel
wise ice
#

yes

#

and it should have a method for each of its main things it controlls

#

so the first set of options is register/list/exit. Exit doesnt require a method, thats just a break

#

but i'm not sure on the nesting of register/list

modern kernel
#

One message removed from a suspended account.

#

One message removed from a suspended account.

wise ice
#

the exact same way, but im saying to take that switch inside of a switch and make that a private method

modern kernel
#

One message removed from a suspended account.

wise ice
#

yeah the while would wrap that switch

#

so the first layer of menu options are Register something, list something, or exit?

modern kernel
#

One message removed from a suspended account.

wise ice
#

so using what you had before I'll update the outer switches on the template: ```java
public class Controller {
private ArrayList<User> userList = new ArrayList<>();

public Controller() {}

public void run() {
    JOptionPane.showMessageDialog(null, "Bem vindo! Voce está no sistema da ouvidoria!", "Ouvidoria", 1);
    
    while (true) {
        String[] menu = { "Register", "List", "Exit"};
        int menuInput = JOptionPane.showOptionDialog(null, "Escolha uma opção", "Ouvidoria - Menu", 0,  3, null, menu, menu[0]);
        if (menuInput == 2) {
            break;
        }
        switch (menuInput) {
            case 0 -> startRegistration();
            case 1 -> listInformation();
        }
    }
}

private void startRegistration() {

}

private void listInformation() {

}``` that all make sense?
modern kernel
#

One message removed from a suspended account.

#

One message removed from a suspended account.

wise ice
#

i updated mine to remove the static option constants, but similar. You should still have the menuinput dialog box inside the loop as you originally had

modern kernel
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

wise ice
#

yup seems good. and yeah for now

#

yeah im looking at it and your if condition seems backwards

#

you check if there are no manifestos, then say there are no registered users

#

You should be checking users, which is the local userList.isEmpty()

#

and since you're scoped to a method you can simplify it to java if (userList.isEmpty()) { JOptionPane.showMessageDialog(null, "Nenhum usuário cadastrado! \nVocê precisa cadastrar um usuário primeiro.", "Ouvidoria - Manifestação", 2); return; } // normal processing String userList = "Lista de usuários"; for (Usuario user : manifestacaoList){ userList += "\n- " + user.getNome(); } JOptionPane.showMessageDialog(null, userList, "Ouvidoria - Manifestação", JOptionPane.WARNING_MESSAGE); ...

modern kernel
#

One message removed from a suspended account.

modern kernel
wise ice
#

yeah. and crap yeah i forgot to mention a step

modern kernel
#

One message removed from a suspended account.

wise ice
#

separate manifesto from user registration

#

private private void createUser() and private void createManifesto()

#

or whatever you want to name them

modern kernel
#

One message removed from a suspended account.

wise ice
#

then that case 0: // Cadastrar uma manifestação
would go inside createManifesto

#
    private void startRegistration() {
        int menuInput2 = 0;
        String[] menu2 = { "Manifestação", "Usuário", "Voltar"};
        menuInput2 = JOptionPane.showOptionDialog(null, "Escolha uma opção", "Ouvidoria - Cadastrar", 0, JOptionPane.QUESTION_MESSAGE, null, menu2, menu2[0]);

        switch (menuInput2){
            case 0: // Cadastrar uma manifestação
                registerManifest();
                break;

            case 1: // Cadastrar um usuário
                registerUser();
                break;

            case 2: // Voltar para o menu principal
                break;
        }
    }```
roughly
#

and then copy the cases again into their own method

#

using the original code:

    private void registerManifesto() {
        if(manifestacaoList.size() == 0){
            JOptionPane.showMessageDialog(null, "Nenhum usuário cadastrado! \nVocê precisa cadastrar um usuário primeiro.", "Ouvidoria - Manifestação", 2);
        } else {

            String userList = "Lista de usuários";
            for (Usuario user : manifestacaoList){
                userList += "\n- " + user.getNome();
            }
            JOptionPane.showMessageDialog(null, userList, "Ouvidoria - Manifestação", JOptionPane.WARNING_MESSAGE);

            int menuInput3 = 0;
            String[] menu3 = { "Reclamação", "Sugestão", "Elogio"};
            menuInput2 = JOptionPane.showOptionDialog(null, "Escolha uma opção", "Ouvidoria - Cadastrar", 0,  3, null, menu3, menu3[0]);

            JTextField nomeUserInput = new JTextField();
            JTextField descricaoInput = new JTextField();
            Object[] message4 = {
                    "Nome do usuário:", nomeUserInput,
                    "Descrição:", descricaoInput,
            };

            JOptionPane.showConfirmDialog(null, message4, "Ouvidoria - Usuário - Professor", JOptionPane.OK_CANCEL_OPTION);

            if (nomeUserInput.getText().equals("") || descricaoInput.getText().equals("") ){
                JOptionPane.showMessageDialog(null, "Erro ao cadastrar usuário! \n Campo de texto vázio!", "Ouvidoria", 0);
            }

            SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
            Manifestacao manifestacao = new Manifestacao();
            manifestacao.setDataManifestacao(dateFormat);
            manifestacao.setDescricao(descricaoInput.getText());


            switch (menuInput3){
                case 0: // Reclamação
                    manifestacao.setCategoria(Categoria.CATEGORIA_RECLAMACAO);
                    break;
                case 1: // Sugestao
                    manifestacao.setCategoria(Categoria.CATEGORIA_SUGESTAO);
                    break;
                case 2: // Elogio
                    manifestacao.setCategoria(Categoria.CATEGORIA_ELOGIO);
                    break;
            }
        }
    }```
modern kernel
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

wise ice
#

yes

#

which will bring you back to the main menu

#

also .isEmpty() works on strings

#

if (nomeUserInput.getText().isEmpty() || descricaoInput.getText().isEmpty()) {

modern kernel
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

wise ice
#

it shouldnt be in the if

modern kernel
#

One message removed from a suspended account.

wise ice
#

after the return just put that copy paste into the normal part of the method (no indentation/nesting)

modern kernel
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

wise ice
#

within this method its a little confusing / inforrect i think

#

the title at least

#

"Ouvidoria - Usuário - Professor"

modern kernel
#

One message removed from a suspended account.

#

One message removed from a suspended account.

wise ice
#

also the empty input should probably return, unless you want to loop until valid inputs

#

this part will have to change a little bit to fetch the user and add the manifest to them

modern kernel
#

One message removed from a suspended account.

wise ice
#

make a method to return a user by ID or name (it seems the popup box is asking for name, not ID though)

#

i believe in ur ability to create a private User getUserByName(String name) in the controller

modern kernel
wise ice
#

i meant that if the user left one of the fields blank you could wrap that section in another loop until its non-blank, but if its not a requirement just return early (since they didnt provide enough data)

modern kernel
#

One message removed from a suspended account.

#

One message removed from a suspended account.

wise ice
#

yeah so it just goes back a menu if it fails

modern kernel
#

One message removed from a suspended account.

wise ice
#

well only the previous step

#

it wont return to the main menu

#

eh maybe it would

#

i guess it depends on how you wrap things in loops or not

modern kernel
#

One message removed from a suspended account.

wise ice
#

also i made u a helper method if you want to use it java private static boolean anyEmpty(JTextField... fields) { for (JTextField field : fields) { if (field.getText().isEmpty()) { return true; } } return false; }

then you can just say if (anyEmpty(nomeInput, cpfInput, dataNasciInput, cargaHoraInput))

restive shoalBOT
wise ice
modern kernel
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

wise ice
#

well its defined in the user class already so thats redundant

modern kernel
#

One message removed from a suspended account.

wise ice
#

just manifestacaos is enough

#

well you havent used it yet. will have to possibly create a getter/setter for it. Realistically you only need a getter, then an 'adder'

#

addManifesto(Manifesto)

modern kernel
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

wise ice
#

yeah its roughtly what you had at the start. Theres still a few issues though from the original version

#

(like manifestos are created and then forgotten)

#

also the indenting on registrarManifestacao is messed up

#

it can also use seVazio

modern kernel
wise ice
#

yeah

#

here you need to find the user and add it to their manifestos

#

and also in that snippet seVazio can shorten the if

modern kernel
wise ice
#

you still have the original else part indented

modern kernel
#

One message removed from a suspended account.

wise ice
#

yeah it wont change the execution of the code but u should fix it

modern kernel
#

One message removed from a suspended account.

#

One message removed from a suspended account.

wise ice
#
        if (nomeUserInput.getText().equals("") || descricaoInput.getText().equals("") ){
            JOptionPane.showMessageDialog(null, "Erro ao cadastrar usuário! \n Campo de texto vázio!", "Ouvidoria", 0);
        }``` the if condition
#

the little helper method to OR them together can be used there

#
        if (seVazio(nomeUserInput, descricaoInput)) {
            JOptionPane.showMessageDialog(null, "Erro ao cadastrar usuário! \n Campo de texto vázio!", "Ouvidoria", 0);
        }```
#

u used it in the other spots

modern kernel
#

One message removed from a suspended account.

#

One message removed from a suspended account.

wise ice
#

thats called varargs in english btw. Its nice to use every now and then

#

for variable number of arguments

modern kernel
#

One message removed from a suspended account.

#

One message removed from a suspended account.

wise ice
#

its just Controller

#

part of MVC (Model View Controller) architecture

modern kernel
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

wise ice
#

yes thats what its currently doing

modern kernel
#

One message removed from a suspended account.

#

One message removed from a suspended account.

wise ice
#

i think the user should just remember their username

modern kernel
#

One message removed from a suspended account.

wise ice
#

u cant assign a single manifest to a list of manifests, but that shouldnt be in the constructor

#

only have the first 3 args

#

the default initialization to new arraylist will just make an empty list for each new user

modern kernel
#

One message removed from a suspended account.

#

One message removed from a suspended account.

wise ice
#

yes none of the users should take a manifesto on creation

#

when u first create them they shouldnt have any

#

that would be a different request

modern kernel
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

wise ice
#

no it has a reference to the user object

modern kernel
#

One message removed from a suspended account.

wise ice
#

u still need a findUserById/Cpf/Username whatever, user.addManifest and user.getManifests at least

modern kernel
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

wise ice
#

yes

modern kernel
#

One message removed from a suspended account.

wise ice
#

yes but pedro should be in the form of a variable

modern kernel
#

One message removed from a suspended account.

#

One message removed from a suspended account.

wise ice
#

yeah but put it in a method that takes in the name

#

and yes you'll have to loop

modern kernel
#

One message removed from a suspended account.

#

One message removed from a suspended account.

wise ice
#

pass a string to the method and replace nomeUserInput.getText() with that parameter string. also Usuario should just be user

#

the return type shouldnt be void either

modern kernel
#

One message removed from a suspended account.

wise ice
#

findUser(String name)

modern kernel
#

One message removed from a suspended account.

#

One message removed from a suspended account.

wise ice
#

ur getting closer

#

what do u do if theyre equal

modern kernel
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

wise ice
#

i mean thats the end goal

#

but in order to do that u need the matching User object

modern kernel
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

modern kernel
#

One message removed from a suspended account.

wise ice
#

u dnt need a boolean method u want a user returning method

#

i mean yeah thats an existance search but u need the specific user, assuming they exist

modern kernel
#

One message removed from a suspended account.

wise ice
#

private Usuario findUser(String name)

modern kernel
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

wise ice
#
    private Usuario findUser(String nome) {
        for (Usuario u : usuarioArray) {
            if (u.getNome().equals(nome)) {
                return u;
            }
        }
        return null;
    }```
I need to go to sleep
#
Usuario user = findUser(inputNome);
if (user == null) {
  // say user not found, return early
}
user.addManifesto(manifest);
hidden ibex
#

I'd use the Stream filter method, and you can then use Optional.

wise ice
#

this guy is 1 month into programming that's not going to be a realistic option, but yes that is a nice way to filter

hidden ibex