Hello,
I am currently in a programming Logic and design course at my local community college and I was give 5 chapters to read because I join the class late. I am now in 3 and I am confuse with a method that the book does not explain too much. I am stuck at the get and set method. I have read the chapter twice and I cant seem to figure how to use it in a different way from what the book shows.
Here is the example of how the books explains in pseudocode.

public class TestPizza
   public static void main()
      pizza large
      large.setPizzaSize(18)

      print “A size large pizza is “ large.getPizzaSize() “ inches in diameter”
   return
endclass

I can see that the 18 was already set in the code but the book didnt explains how a user can input the size of the pizza manually. So can some one explain how to use the get and set method or point me to the tutorial? I check the search and only found things about java that didnt explain very well for me to understand.

So if your code is Java, why are you posting it in the C++ forum?

For setting the pizza size, first of all you get the user's input, and store it in a variable. Such as: int thesize=stdin.readLine(); Then you can set the pizza's size: large.setPizzaSize(thesize); Hope this helps

So if your code is Java, why are you posting it in the C++ forum?

For setting the pizza size, first of all you get the user's input, and store it in a variable. Such as: int thesize=stdin.readLine(); Then you can set the pizza's size: large.setPizzaSize(thesize); Hope this helps

It's java? I did not know that. The books just says that its just logicals to writing programical codes. And thanks for replying.

Member Avatar for iamthwee

It's java? I did not know that. The books just says that its just logicals to writing programical codes. And thanks for replying.

Don't you have any notes from school?

It's java? I did not know that. The books just says that its just logicals to writing programical codes.

C++ code *should* always start it's main program code with:

int main() { /*...*/ }

(some ignorant people still use void main , which is NOT encouraged.)

Whereas Java's main code is always inside of a class, and looks like this:

public static void main() { }

Of course the code you posted was not *real* Java, as it did not use any braces. But you get the idea.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.