Lab 19

Apple Maker

 

Objective:

 

Write a program that creates a class Apple and a tester to make sure the Apple class is crisp and delicious.

 

First create a class called Apple

 

Finally create a class called AppleTester

 

Example Dialog:

 

Welcome to the apple tester

 

Creating a default apple

Printing the default apple’s values

Name: Gala Weight: 0.5 Price: 0.89

 

Creating another apple

Setting the new apple’s values to the following valid values “Granny Smith” 0.75 0.99

Printing the new apple’s values

Name: Granny Smith Weight: 0.75 Price:0.99

 

Creating another apple

Setting the new apple’s values to the following invalid values “iPad” 2.5 -200

Invalid Name

Invalid Weight

Invalid Price

Printing the apple’s values which should have not changed from the default values

Name: Gala Weight: 0.5 Price 0.89

 

Lab Report Questions:

  1. In your own words describe what a class is used for.
  2. In your own words describe encapsulation as it relates to object oriented programming

 

Finally:

Upload ALL java files to the dropbox