Here we will talk about the following Java Program called "ShoppingCart.class and ShoppingCart.class" both belong to the same Java class called "ShoppingCart". The idea behind this mini project was to develop an Online Shopping Cart statement at the end of the purchase. Likewise in this scenario you will see the Java code that is required to generate that Result or a Total amount in the final stages of your purchase. So let's START!.
Here as you can see we have a public class called "ShoppingCart. All the listed private variables are difference in terms of its attribute. For example the "name of the item" is called "selectItemName". Likewise it can be any other name, but "select" pertaining to a certain selected item at the Online Shopping Cart before the Check out. This variable will be the name of the item, so it's not a number, therefore we call it also "String" meaning it's a word, and not an "int" for a number.
The image above showcases all the list of variable like the name of the item, payment type, the price of the item,etc.
Likewise this image lists all the attributes and methods pertaining to these Online Shopping Cart components. Because before we move to the next phase of the program, these components must be defined in order to generate a successful Result.
This is the next Image of the code
Why is this important?
Well, it's the only method that will return a generates answer which is the result or the Total amount before we check out with our item.
Moreover, this is the calculation that the program will perform, and if you LOOK closer, the word "return" is pertaining to the type of method which is returning an integer, or a number to this calculation. And this method is a calculation of the item's price plus the added price of the tax, and altogether is the Result or the Total amount that we are looking for. Hence this answer will be generated with the name of this method, therefore we write "return" to perform this math calculation and return a total number.
The image below is a representation of our main argument, only in the main section of our argument we will include all the methods and create this following object, which means like an extension to our method and class. Therefore, our class is a "ShoppingCartItem" and the name of the other class is "ShoppingCart" so the name of the object needs to be something even different. Thus, we have created a random name, let's called it a, "obj1" simple and straightforwards which is our only object, therefore "obj1". Inside this object, we have included a statement instead of a variable. And just for an example this statement is the name of the course that we will be paying for at the Online Shopping Cart. So this will be the name of our item just as an example. Next we have separated this statement with another statement by using a comma, and the next statement says, "Debit", meaning the type of payment that we will use to pay this course.
Furthermore, we have created our object, and have assigned a statement to the object. Now we have written all of our code, and finally we must call the parameters including the methods assigned earlier. Like the item cost that will give a number, in this example we have given a number of 750, meaning $750. And we have set a tax cost of $5.0. As well as the number of items representing it'd quantity. In this case, quantity "1", because it's only 1 item.
Here in the next image below we write "System.out.println()" to call upon all of our methods with our assigned object. As well as any statement like the welcoming statement to Online Shopping Cart, and a closing statement notifying the Customer, "This concludes your statement!".
This is what we get after we RUN our Java Code: