Custom Exceptions Objective: Implement a complete system from scratch using two custom Java objects that are self-validating
Question:
Custom Exceptions
Objective: Implement a complete system from scratch using two custom Java objects that are self-validating and a driver class to create those objects.
Related SLOs:
SLO #1: Use an appropriate programming environment to design, code, compile, run, and debug computer programs.
SLO #2: Demonstrate basic problem solving skills: analyzing problems, modeling a problem as a system of objects, creating algorithms, and implementing models and algorithms in an object-oriented computing language.
SLO #3: Illustrate basic programming concepts such as program flow and syntax of a high-level general-purpose language and basic security practices.
SLO #4: Demonstrate working with primitive data types, strings, and arrays.
Instructions:
Create the necessary Java classes that will simulate an environment, using two custom Java objects that are self-validating. In your past assignments and lectures, we have simulated a School environment. In the example below, I am simulating a Store environment. You may simulate any environment of your choosing, but not School or Store.
Note: if you're totally stuck on thinking of an idea you can simulate, or if you want to check if your idea is okay, feel free to e-mail me! :)
Your program MUST:
Model at least 2 related objects that self-validate for all object characteristics (minimum 3).
Note: for String variables, you can validate to make sure the String is at least a certain length
Use the objects' constructors to create 1 valid object of each of the 2 different objects.
Call 2 methods for each of the 2 objects you are required to create, without resulting in an exception being thrown.
Use the constructor to attempt to make an invalid object.
Call 1 set method for each of the 2 different objects that results in an exception being thrown.
Your program must conform to the Java coding standards reviewed in class. This includes the requirement that you must comment your class files and all of your methods. You don't have to use Javadoc tags for your get methods, nor for set methods that are not validating the object.
Your program should not use code/concepts we have not yet covered. You must demonstrate that you have mastered the concepts covered in class.
Your program should follow the examples as shown in the lecture videos, including separate files and naming conventions.
Remember to always begin each class with the following documentation comments:
/**
* Short description of the program.
*
* @author Last Name, First Name
* @assignment ICS 111 Assignment XX
* @date Today's Date
* @bugs Short description of bugs in the program, if any.
*/
Expected Output:
This is an example of what your program may output:
----jGRASP exec: java ManuelNikki12
This program models a rock climbing store.
This model contains 2 objects: ClimbingShoe, Chalk
I am printing the ClimbingShoe object with System.out.println(shoe1.toString());
Shoe Brand: La Sportiva
Shoe Style: Miura
Shoe Price: $150
Shoe Size: 6.5
Amt in Stock: 9
I am printing the Chalk object with System.out.println(chalk1);
Chalk Brand: Tokyo Powder Industries
Chalk Name: Black
Chalk Type: Powder
Chalk Size: 135g
Chalk Price: $25
Amt in Stock: 46
I am using a set method to change the ClimbingShoe object shoe1's price to 127, then printing again:
Shoe Brand: La Sportiva
Shoe Style: Miura
Shoe Price: $127
Shoe Size: 6.5
Amt in Stock: 9
I am using a get method to print the Chalk object chalk1's brand and name in this sentence:
Santa, please bring me Tokyo Powder Industries Black for Christmas.
Chalk size should be a number between: 0 - 1000
I will try to create an invalid object: a Chalk object with a chalk size of -100 grams.
Error: -100 grams is not a valid size for this chalk.
Chalk type should be one of these types: Powder, Block, Ball, Liquid
I will use a set method to try to change chalk1's type to: Crunchy
Error: Crunchy is not a valid type - please enter one of the following:
- Powder
- Block
- Ball
- Liquid
Shoe size should be a number between: 3 - 50
I will use a set method to try to change shoe1's size to: 100
Error: 100 is not a valid shoe size - please enter a number between 3 - 50
----jGRASP: operation complete.
Important: Make sure you use System.out.print for output as needed to show that the changes you intended to make actually went through.
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill