From the course: Oracle Java Foundations

Unlock this course with a free trial

Join today to access over 24,000 courses taught by industry experts.

Operators: Demo

Operators: Demo

(bright music) - [Instructor] Exercise 3-2, using numeric and text variables. In this exercise, you'll create a new Java class called clothing, add properties for the description, price and size, and set the initial size to M by default. We will also use clothing in the main method of the shop class, add two variables to represent clothing item one and item two. We'll set the clothing item properties and we'll print details of those clothing items as common to limited text. Then we'll have add a variable called tax and we'll calculate tax based on the total items purchased. Okay, let's get started. First off, create a new Java class. So we come back here to duke.choice, right click, new, Java class. This one is going to be called clothing. It'll be under duke.choice. So we'll call this clothing and it is under duke.choice. It looks good. Click finish. There's our clothing class. And now we need, let's see, description, price, and size, string, double, and string. So we need a string…

Contents