Lengkap

Pencil Box

Part I:

Create a new Java class named Pencil that has the following fields:

color (String), brand(String), price (double)

A pencil can have one of the following colors: Orange, Yellow, Brown, or Blue (all other colors are considered as invalid and default to Brown); The length of a band name is within the range of [3, 20]. The price of a pencil is limited to [$0.01, $200] (for all other prices, set the price to $0.50). The following rules are applied when a client program tries to set brand name:

Because the length of a brand name is limited to [3,20], if the length of a brand name is less than 3, you should repeat the brand name until it meets the length requirement. For example, if the brand name is "A", you are going to repeat it three times so it becomes "AAA", which meets the length requirement. If the length exceeds 20, your program should take the first 20 characters as its brand name.

Constructor - The constructor should accept the color, brand, price as arguments. These values should be used to initialize the pencil color, brand, and price. Getter Methods and setter methods for all instance variables.

toString method which returns info about the pencil in the following format:

PencilColor Brand unitPrice

Pencil color occupies 10 spaces(left aligned), brand name 20 spaces(right aligned), and unit price 10 spaces (hint: use [login to view URL]() method)

For example:

Black BIC $0.90

Part II:

Create a class named PencilBox. There are exactly 10 pencils in each PencileBox with two mixed colors (at your choice). The PencilBox has the following method:

Constructor(Pencil type1, int qty1, Pencil type 2, int qty2)

a method called totalCost which returns the total cost (total price of the pencils in a pencilBox)

toString method which returns the info about pencils in the box.

For example, there are 5 brown and 5 yellow color pencils in a pencilBox, the unit price for a brown color pencil is $0.90 and $0.80 for yellow ones. Then the toString method return a String as shown below:

Brown BIC $4.50

Black CIS201 $4.00

Each pencil box stores exactly 10 pencils. For all invalid quantities, your program should set 5 to each color, so altogether, there are 10 pencils in the pencil box.

No getter or setter methods are necessary for this PencilBox class.

Part III:

Write driver (tester) class named [login to view URL] that uses your Pencil and PencilBox class:

1. create two pencil objects

2. create a PencilBox object that uses the pencil object created in step 1

3. printout th pencilBox as follows

Color Brand Subtotal

-------- --------- ----------

Brown BIC $4.50

Black CIS201 $4.00

--------------------------------------

Grand Total: $8.50

Kemahiran: Pengaturcaraan C, Pengaturcaraan C++, Java, Javascript, Kejuruteraan Perisian

Lihat lagi: www pencil box design, type algebra multiple choice questions online, doc type css multiple choice, pencil box staples, pencil box walmart, plastic pencil boxes, pencil box target, sterilite pencil box, pencil boxes bulk, large pencil box, cheap pencil boxes, java, pencil box design, asterisk detect called number type, pencil box illustrator file, jquery select box manipulation use, smarty use object type, use illustrator pencil, fatal error use object type smarty, rich text box use asp

Tentang Majikan:
( 9 ulasan ) Woodbridge, United States

ID Projek: #17139861

Dianugerahkan kepada:

koustav2006

HI...I am good at core OO programming in Java along with data structures and algorithms and can help you with the class implementations and methods. please contact me as soon as possible for a discussion.

$45 USD dalam sehari
(140 Ulasan)
6.0

10 pekerja bebas membida secara purata $109 untuk pekerjaan ini

Yknox

Hello, How are you? I am Wen, WEB developer in China I've just read your project in details As you can see, I'm a certificated freelancer with over 1000 good reviews from hundreds clients I've done good jobs in any Lagi

$155 USD dalam 3 hari
(845 Ulasan)
9.0
$120 USD dalam 3 hari
(74 Ulasan)
6.0
sysdesigner13

Hi, bro. Nice to meet you. I have read your description very carefully. I am a long experienced software developer and completed a lot ofJava projects. I am confident in your project and I can finish your proje Lagi

$100 USD dalam 0 hari
(58 Ulasan)
5.6
$155 USD dalam 3 hari
(29 Ulasan)
5.2
$100 USD dalam 2 hari
(31 Ulasan)
4.3
MMAtechnology

Hi, Ready start work right now. we have been doing website and Mobile development for the past 4 years, we have a good of experience and a great eye for software development. we are able to offer competitive p Lagi

$155 USD dalam 3 hari
(2 Ulasan)
3.1
$30 USD dalam 3 hari
(10 Ulasan)
3.1
webplus0404

Hi, I am expert in Java. I am very familiar with Pencil Box. I read description of project carefully. I can do your project perfectly. Thanks.

$100 USD dalam 3 hari
(1 Ulasan)
0.6
$133 USD dalam sehari
(0 Ulasan)
0.0