java logic for tagmaker program

so i've taken an intro to programming class (using c++) a year ago--and it's safe to say i've forgotten a lot of it. i'm taking an object-oriented java course and i've tried creating a few programs with little success. i've decided to go back to basics and start using pseudocode--but i want to see if my logic is correct.

so here's the first program:

each delegate to a certain conference must wear a tag showing their name and the organization they represent as shown below:

write a class called TagMaker that prints out tags. supply methods to (a) set the name (b) set the organization (c) print tag with the name and organization (d) clear the name and organization (e) print a blank tag. then write a TagTester class to test the TagMaker class.

so this is the pseudo code (or logic) that i've come up with for the program:

TagMaker main class:
Prompt user to enter in first and last name, as well as their organization.
Read user input for the name and organization.
Return user input.
Write conference tag showing the person's information.
Clear information.
Print blank tag.

1. i assume i would have to import a few java libraries. i'm pretty sure i would use

Java Code:

java.util.Scanner

and

Java Code:

java.io.*;

2. afterwards i would declare the instance variables (private, i assume). static too? so for example:

Java Code:

private static string firstName

3. i'm not sure if this program requires a constructor...being that i'm supposed to clear the program at the end anyway.

6. to print out both tags, would i write most of the code as part of a loop and make an "if" statement where the user input is valid, it prints out a tag with information, and another "if" statement that would automatically clear the buffer? this part confuses me.

7. last i would create a tester class that would primarily be responsible for the program's output.

ta-da? please help :/. i did try writing the code too but all i get are compiler errors so i felt the need to start from scratch.

Re: java logic for tagmaker program

Unless I'm misunderstanding the setup that you're looking for, your setter isn't completely correct.
The variables that are this.variable are class variables. You are correct, that you use a setter function to change those variables to something new in an instance, but you need to pass along what you want to set it to.
In other words, one of the parameters for the setter must be, String first
That way, you know what you are making this.variable.

If you wanted to do a very simple program, you could simply
1) Ask for the name, save the name to a string
2) Ask for the organization, save the organization to a string
3) Print out a line of #s, followed by 2#s, name, 2#s, new line of #s, etc. until the whole thing is printed
4) Change name to empty
5) change organization to empty
6) repeat step 3

This is the way a student in an intro class would do it - all in the main method.

From what I can see, you could also create a printTag() method that does the printing, and the setting methods (as well as a constructor if you want to do it in a separate class).

So maybe,
(optional first step - write a separate class for the tag creation - would be better if you had a large amount of people to write tags for, and if you wanted to reference to various tags. Would be done by creating a new class called TagMaker, then doing TagMaker smith = new TagMaker(); though you could do this in the same class)
1) Get name from user, setName(name)
2) Get organization from user, setOrg(organization)
3) printTag() (which will use the oran and name you just set
4) setName(""), setOrg("")
5) printTag()

We assume that this.first is a instance variable.
But what are you setting this.first equal to. What is the value for first? You didn't pass any value along to your set method.

I guess you could think about it like a dialogue between two people? If you are talking to your friend and ask him to change the channel, but neglect to mention which channel to change it to, how does he know what channel to go to? You have to pass along the parameter - the actual channel number/name - so that your friend can change the channel.

Re: java logic for tagmaker program

I believe AlexGraal means that this.first is referencing an instance variable and not a class variable, class variables have the static modifier and are created only once for each class and not each instance of the class. The firstName variable does not need to be static either. You would make it private String firstName; and then use a public getter/setter to access it, also known as encapsulation.

Re: java logic for tagmaker program

okay, so i tried setting it up. i got the code to accept the user input and print out a tag...but i did it without a tester class (i'm scared of those, and it wasn't working so i stopped using it. any suggestions there?) and i've experimenting with codes that would clear the scanner to print out a blank tag also but it kept messing up the program so i took it out.

i tried looking in my textbook for something that would work but nothing i've tried has worked so far ): i also read something about a clone method that seemed like it *might* work (unless i've misunderstood it's function) but it's in chapter 13 and my class is only in chapter 6 right now.