SlideShare a Scribd company logo
1 of 50
Mark L. Simon II
Individual Project / IP 1 thru 5
IT110 -1404A-01
Introduction to Programming
Professor: Mazen Alkhatib
10 November, 2014
Colorado Technical University
PROGRAMMING 2
Table of Contents
Chapter One – Fundmentals............................................................................................................ 3
Overview..................................................................................................................................... 3
Java Fundamentals ...................................................................................................................... 4
Re-Factored Java Code ............................................................................................................... 4
Java Runtime Environment......................................................................................................... 6
Conclusion .................................................................................................................................. 8
Chapter 2 - Java Control Structures ................................................................................................ 9
Control Structures ....................................................................................................................... 9
Script for Method........................................................................................................................ 9
Splash Pages for Program ......................................................................................................... 11
Conclusion ................................................................................................................................ 13
Chapter 3 - Error Handling and File Input or Output ................................................................... 14
Errors and Exceptions ............................................................................................................... 14
Script for Input / Output, Error and Exception Handling ......................................................... 15
Conclusion ................................................................................................................................ 22
Chapter 4 - Object-Oriented Techniques ...................................................................................... 23
Object-Orientated Class Script.................................................................................................. 24
The Output ................................................................................................................................ 30
Conclusion ................................................................................................................................ 35
Chapter 5 - Inheritance and Polymorphism .................................................................................. 36
Arrays and Sub Classes............................................................................................................. 36
Virtual Output ........................................................................................................................... 42
Screen Shots of Operation with Arrays ........................................................................................ 45
Conclusion ................................................................................................................................ 50
References..................................................................................................................................... 50
PROGRAMMING 3
Programing IT110
Chapter One – Fundmentals
Overview
Welcome to the world of beginners programming where you can lose your mind crunching the
script or letting the developer program do it for you. In this phase, I was given a few lines of
script to design my own opening statement or splash page on a web site. My website entails
selling computer hardware components at reduced prices. The primary purpose of this website
welcome splash is to aid homeowners in getting items for their computers without paying the
exorbitant prices normally seen with computer building. In the website the customer has the
choice of various components to choose from. There will be mobos, processors, heat sinks,
RAM, graphics cards, hard drives, cases, and monitors. In a use case scenario the graph will
look as seen below in figure1-1.
(Figure 1-1)
PROGRAMMING 4
Java Fundamentals
I had a decision to make and that decision was weather Eclipse or NetBeans would be used to
formulate this program. I initiated Eclipse and tried integrating everything into one program. I
quickly found that Eclipse was not very user friendly for the first time user. It would tell me
what was wrong, but wasn’t able to quickly rectify mistakes for me, or seem to want to debug
each of the steps responsible for the script halting and giving errors. I threw the file all out, shut
down Eclipse and started the NetBeans console. This program easily started a new page, could
quickly integrate the PizzaRUS.java file in without delay and it was easy to do the fundamental
integration. Once they were both on the NetBeans board, the console quickly told me the
problems; where they were at, and possibilities for fixes by the quick click of a button. Once the
debugger was run and the j-options problem was worked, it all came together to run and create
the windows pop-ups needed for introduction. Below is the refactored code, which made it all
happen.
Re-Factored Java Code
/*IT110-1404A-01 (Introduction to Programming)
* Claw Concepts Phase 1 IP
* Created on 10/09/14 by Mark L. Simon II
* Instructor : Mazen Alkhatib
*/
package ClawConceptsPhase1;
import javax.swing.JOptionPane;
/**
*
* @author Mark Simon
*/
public class Claw_Concepts {
PROGRAMMING 5
public static void main(String[] args){
// declare variables
String openingMsg, nameInputMsg, customerName, nameOutputMsg,
returnInputMsg, customerReturn, returnOutputMsg,
greetingOutputMsg, outputMsg;
// display opening message
openingMsg = "*** Welcome to Claw Concepts Ordering System ***n"
+ " Shop for the part you desire!";
JOptionPane.showMessageDialog(null, openingMsg);
// get required input using dialogs
nameInputMsg = "Please enter your name: ";
customerName = JOptionPane.showInputDialog(nameInputMsg);
returnInputMsg = "Are you a returning customer (yes or no)? ";
customerReturn = JOptionPane.showInputDialog(returnInputMsg);
// build output strings
nameOutputMsg = "Welcome " + customerName + ".nn";
returnOutputMsg = "Your return customer status is " + customerReturn + ".n";
greetingOutputMsg = "Thank you for visiting Claw Concepts!" + "nn"
+ "Your order will be shipped within the next 24 hours.n";
// create and display output string
outputMsg = nameOutputMsg + returnOutputMsg + greetingOutputMsg;
JOptionPane.showMessageDialog(null, outputMsg);
System.exit(0);
} // end main()
} // end class ClawConceptsPhase1
(Figure 1-2)
PROGRAMMING 6
Java Runtime Environment
As I ran the program the following windows started popping up. I placed the required
information into each of the windows to ensure it would take the information and change to the
next function and then ran it again without placing information in to the boxes. The program
still sequenced through the motions and then ended the function.
(Figure 1-3)
As we see above on (figure 1-3), the first splash screen represents “Claw Concepts Ordering
System”. As soon as “OK” is hit the next splash screen appears, as is seen in (figure 1-4).
(Figure 1-4)
PROGRAMMING 7
As we see in (figure 1-4), I am able to easily place my name in the box for temporary
verification of customer. Once the “OK button is clicked the next splash window pops up as is
seen in (figure 1-5).
(Figure 1-5)
In figure 1-5 it represents the question to the customer if they are a reoccurring customer.
I have typed “Yes I am” in the box to see if it will annotate the process. Once this is done, I hit
the “OK” button to move on through the program. What is observed next is in (figure 1-6).
(Figure 1-6)
PROGRAMMING 8
As we can see in (figure 1-6), my name and the customer status have exactly what I
entered into the prior boxes. The run test is now complete.
Conclusion
For the phase one assignment we were asked to integrate a program into Java NetBeans
or Eclipse to make it a splash screen questionnaire for our web site. Mine was exhibited as
“Claw Concepts” and integrated into a form of Java pseudocode with the steps needed to execute
the program. Upon completion of the program and pulling out un-needed lines of script, the file
was capable of initiating and presenting screen shots of its execution. Refactoring was a key
concept in ensuring proper function and execution of the program, with the help of the
debugging tools within the program. In the end all functions executed for the needed operation.
PROGRAMMING 9
Chapter 2 - Java Control Structures
Control Structures
Control structures are the very essence of what makes a Java program run without
sequentially stating each line within a given program. By using decision making statements,
control statements, looping statements, branching statements, break statements, and return
statements; a program can choose which parameters are needed given the equation it’s chewing
on. In this portion of the individual project, we have taken the opening “JOptionPane” area and
integrated it with the “getStringInput” scenarios within the JOptionPane program. The result of
this incorporation is to output direct customer needs based on the input from the customer. This
is then all displayed within the splash panes. As we see below (Figure 2-1), the initial program
was scribed into the (CC Method) script.
(Figure 2-1)
Script for Method
import javax.swing.JOptionPane;
public class CC_method_review{
private static String getStringInput(String prompt)
{ String returnprompt=null;
for (int i =1; i <= 3; i++)
{returnprompt = JOptionPane.showInputDialog(prompt);
if(returnprompt.isEmpty())
{JOptionPane.showMessageDialog(null, "Invalid Entry!!");
if (i == 3) System.exit(0); }
else
break;
}
PROGRAMMING 10
return returnprompt;
}
private static double totalCost(int InumberItems, double costPerItem,
double discount, double taxRate)
{double Total_Cost;
Total_Cost= (InumberItems*costPerItem-
InumberItems*costPerItem*discount
+InumberItems*costPerItem*taxRate);
return Total_Cost;
}
public static void main(String[] args){
String openingMsg;
String prompt,customerName,customerReturn,numberItems,modelType;
int InumberItems;
double costPerItem= 25.00,discount = 0.05,taxRate = 0.08,totalCost ;
openingMsg = "Welcome to Claw Concepts"+"n"
+ "Shop for the part of your desire!";
JOptionPane.showMessageDialog(null, openingMsg);
prompt = "What's Your Name Please?";
customerName = getStringInput(prompt);
prompt = "Are you a returning Customer?" + "n"
+ "Please Enter (Yes or No)";
customerReturn = getStringInput(prompt);
prompt = "How many CD Players would you like?";
numberItems = getStringInput(prompt);
InumberItems = Integer.parseInt(numberItems);
prompt = " Which Brand would you like? " + "n"
+ " Please Enter Model " + "n";
modelType = getStringInput(prompt);
PROGRAMMING 11
totalCost = totalCost(InumberItems,costPerItem,discount,taxRate);
JOptionPane.showMessageDialog(null,"Thank You ForYour Order! " + "
Mr. "+ customerName + "n"
+ "Your Return Status is = " +customerReturn+ "n"
+ "Model Ordered is = " + modelType + "n"
+ "Discount = " + discount+"%" +"n"
+ "Tax Rate = $" + taxRate+"%" +"n"
+ "TotalCost= $"+ totalCost +" n"
+ "Your order will be shipped in 24 hours"+"n");
}
}
Splash Pages for Program
Once this program is run the following results were returned.
Missed type-in one time With Name Entered
Next Run yes/ no with nothing entered. Return with Invalid Entry.
PROGRAMMING 12
Run with Info Entered . Program continues on. How many CD’s with no entry.
Returns the following “Invalid Entry” With CD Amount entered continues on.
Returns the next splash frame. When nothing is entered for brand/model.
PROGRAMMING 13
Now with the brand/model entered. The final outcomes after all entries are
completed.
Conclusion
As has been seen, once the “JOptionPane” is integrated with the “getStringInput” and then
couple with the “showMessageDialog”, we can produce a program with loops, input and
output to work with customers on a web page.
PROGRAMMING 14
Chapter 3 - Error Handling and File Input or Output
Errors and Exceptions
Errors are the formidable adversary to any programmers operation. If one period, semi-
colon or any other character is missed or out of sequence, it can mean hours of back tracking to
find this program stopper. Most functions within the program start with identifying variables.
These are then computed into the main function of the program and a final output is returned
using the display options. Seems quite simple, but as these functions start to rely on one another
for progression of the program, road bumps and pot holes will occur, especially if one variable is
not recognized within another function or sub routine of the program. This is where error
handling tool steps into action and lets the programmer know that a certain line of script will not
function until these errors are dealt with. During this phase, it has been noted that error handling
is paramount to the programs capability of running properly.
A built in error handling tool could be called like the Input/output Exception handler.
This may be inserted to a function to create an exception for the routine, if it is found not to be
true under the Boolean concept or other function. It’s an easy way for the function to be cleared
and an error averted if it doesn’t come out with the correct outcome. The exception handler can
do the job, but it must be written correctly or this function can end up being part of the known
errors.
Listed below is this week’s script for showing error situation and how exception handlers
divert problem areas from throwing errors. Now it just throws exceptions and evaluates it
instead of throwing an immediate error. Review in fig 3-1.
PROGRAMMING 15
Script for Input / Output, Error and Exception Handling
( Fig 3-1 )
package CC_input_output;
/*IT110-1404A-01 (Introduction to Programming)
* Claw Concepts Phase 3 IP
* Created on 10/21/14 by Mark L. Simon II
* Instructor : Mazen Alkhatib
*/
import java.io.File;
import java.io.FileWriter;
import java.io.FileReader;
import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.swing.JOptionPane;
/**
* @author Mark
*/
public class cc_input_output{
private static String getStringInput(String prompt)
{String returnprompt = null;
for (int i =1; i <= 3; i++)
{returnprompt = JOptionPane.showInputDialog(prompt);
if(returnprompt.isEmpty())
{JOptionPane.showMessageDialog(null, "!!!Invalid Entry BUDDY BOY!!!" + "n"
+ " Try Again " +"n");
if (i == 3) System.exit(0);}
else
break;
}
return returnprompt;
}
public static int getNumericInput(int QN)
{boolean er;
er = false;
String tQN;
for(int i=1; i<=3; i++)
{
try{
PROGRAMMING 16
if (QN<1 || QN>99)
{ er = true;
throw new IllegalArgumentException();
}
else
er = false;
}
catch (IllegalArgumentException e)
{
JOptionPane.showMessageDialog( null," Invalid Entry BUDDY BOY!!! ","
ERROR!!",
JOptionPane.ERROR_MESSAGE);
if (i == 3)System.exit(0);
}
if (er == false)
break;
else
{tQN = JOptionPane.showInputDialog( "Please enter quantity" );
QN = Integer.parseInt(tQN);
}
}
JOptionPane.showMessageDialog(null, "Valid Quantity = " + QN);
return QN;
}
public static String VLDNO()
{String phn = null;
Pattern pattern = Pattern.compile("d{3}-s{0,1}d{3}-d{4}");
for(int i=1; i<=3; i++){
phn = JOptionPane.showInputDialog("Please Enter Phone Number in This
Format:###-###-####");
Matcher matcher = pattern.matcher(phn);
if (matcher.matches())
{JOptionPane.showMessageDialog(null, "Your Phone Number is Valid");
break;
}
else
{JOptionPane.showMessageDialog(null,
"WRONG Format DUDE!!! Try Again!!!" + "n"
+ " This time try" + " ###-###-####" + "n" ,
"ERROR",JOptionPane.ERROR_MESSAGE);
if (i == 3) System.exit(0);}
}
return phn;
PROGRAMMING 17
}
private static double totalCost(int InumberItems,double costPerItem,
double taxRate)
{double Total_Cost;
Total_Cost = (InumberItems*costPerItem+InumberItems*costPerItem*taxRate);
return Total_Cost;
}
@SuppressWarnings({"CallToPrintStackTrace", "empty-statement"})
public static void main(String[] args){
String openingMsg;
String prompt,customerName,numberItems,phn,finalMessage;
int InumberItems,Quantity;
double costPerItem = 5.00,taxRate = 0.08,totalCost;
openingMsg = "Welcome to Claw Concepts"+"n"
+ "Shop for the part of your desire!";
JOptionPane.showMessageDialog(null, openingMsg);
prompt = "What's Your Name Please?";
customerName = getStringInput(prompt);
prompt = "How many componets would you like?";
numberItems = getStringInput(prompt);
InumberItems = Integer.parseInt(numberItems);
Quantity = getNumericInput(InumberItems);
phn=VLDNO();
totalCost = totalCost(Quantity,costPerItem,taxRate);
finalMessage = "Thank You For Your Order! " + customerName +"nn"
+ "Quantity entered is confirmed as: " + "[ " + Quantity + " ]" + "nn"
+ "Your (phone nimber) is confirmed as: " + "[" + phn + "]" + "nn"
+ "Tax Rate = $ " + taxRate+"%" +"n"
+ "Total Cost of purchase = " + String.format("$ %.2f",totalCost) +
"nn"
+ "Your order will be shipped within 24 hours." + "n";
try{
File file = new File("order.txt");
PROGRAMMING 18
FileWriter fileWriter;
fileWriter = new FileWriter(file);
fileWriter.write("Hello: n**************** Thank You for ");
fileWriter.write("Your Order****************.n");
fileWriter.write("Your Name Is: " + customerName + "n");
fileWriter.write("Your Quantity Is: "+"[" + Quantity + "]" + "n");
fileWriter.write("Your Phone Number Is: "+ phn + "n");
fileWriter.write("Your Tax rate Is: " + taxRate + "n");
fileWriter.write("Your Total Cost is: " + String.format("$ %.2f",totalCost) +
"n");
fileWriter.write("( Your order will be shipped within 24 hours. )"+"n");
fileWriter.flush();
fileWriter.close();
}
catch (IOException e)
{e.printStackTrace();}
try {
File file = new File("order.txt");
FileReader fileReader;
fileReader = new FileReader(file);
StringBuffer stringBuffer;
stringBuffer= new StringBuffer();
int numCharsRead;
char[] charArray = new char[2048];
while ((numCharsRead = fileReader.read(charArray)) > 0) {
stringBuffer.append(charArray, 0, numCharsRead);
}
fileReader.close();
System.out.println("Order Display:nn ");
System.out.println(stringBuffer.toString());
}
catch (IOException e) {
e.printStackTrace();
}
JOptionPane.showMessageDialog(null,finalMessage);
}
}
As we see above. There can be many areas where errors may pop up in the Try / Catch areas,
but it also develops the exception to handle a possible error of the function. Below is what is
observed when everything runs as planned.
PROGRAMMING 19
When the program is started we will see the following panes.
Here is the starting splash page.
It purports to what we have
done in the method area from
before.
The next splash pane asks for
the name. What if we hit the
key before putting in our
name?
The program happily tells
good ole BUDDY BOY that
the input is incorrect and the
user needs to try it again
This time with the name
entered, we will get the
response in the next frame.
Okay…we are on to the next
frame. Here too, if the
information is entered
incorrectly, a warning will pop
up as described in the next
PROGRAMMING 20
frame.
It’s the same error as the name,
but this time if no entry, the
number “0” or anything above
“99 is entered, it will come
back as an Error. Here, there
was nothing entered.
In this frame a number was
entered, but it was outside the
(1 through 99) range of the
proper selection parameter.
Once a proper number, from (1
to 99) is entered the next screen
will appear.
Now we have a valid quantity
and the program moves on.
Now the phone number is
needed. If it is put in wrong or
nothing at all, the following
message will occur.
PROGRAMMING 21
The DUDE is at it again. All
thumbs and no fingers and
accidently his the return before
entering the phone number.
Now the number is entered
properly. This should return
proper valid compliance in the
next frame.
If we look back at the script,
we can see this as the last input
function before the program
rights it all to file and the
generates a text document
In the package area, we can see
that it has built an order.txt file
saying that it has been written
to a file. Within the file is the
order information needed to fill
the order
As you are nor reading this, so
is the customer, on the return
splash pane below.
PROGRAMMING 22
This is what the customer will
see when they are complete on
their order.
Conclusion
Error checking takes on many forms. Weather it is the lines of code or in the function
that is being run. The error and exception handlers are always ensuring everything has to be
entered in a specific way. This is to ensure proper flawless operation of the program and the
data entered into the program. As has been stated through this phase, error and exception
handling are great tools to ensure accuracy of outcome but it’s wise to keep discernment
when deploying their usages.
PROGRAMMING 23
Chapter 4 - Object-OrientedTechniques
//CC Classes
[Claw Online Ordering | Department:String |Brand:string; Model:String;
Color:String;Size:String|getDepartment();getBrand();getModel();getColor()get
Size
(Figure 4-1)
If we want to add our own classes, also known as “Object-Orientated Design”, we have
to create a class diagram to represent the intended idea for our program. Above, in (figure 4-
1), a representation of the intended classes is illustrated to be able to formulate a structure for
the given idea of the classes to be represented. This is then applied to the script to attain a
functional class system within the program. As is represented below (Figure 4-2), the class
section is designated at the top of the programming. To initiate the various classes entered
within the program. Let’s take a look the script to evaluate how this all works.
PROGRAMMING 24
Object-Orientated Class Script
(Figure 4-2)
/*IT110-1404A-01 (Introduction to Programming)
* Claw Concepts Phase3 IP
* Created on 10/21/14 by Mark L. Simon II
* Instructor : Mazen Alkhatib
*/
import java.io.File;
import java.io.FileWriter;
import java.io.FileReader;
import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.swing.JOptionPane;
/**
* @author Mark
*/
class Parts{
String Brand,model,color,size;
String getSection(String Section){
return Section;}
String getBrand(String Brand){
return Brand;}
String getModel(String Model){
return Model;}
String getColor(String Color){
return Color;}
String getSize(String Size){
{return Size;}
}
}
PROGRAMMING 25
public class claw_classes{
private static String getStringInput(String prompt)
{String returnprompt = null;
for (int i =1; i <= 3; i++)
{returnprompt = JOptionPane.showInputDialog(prompt);
if(returnprompt.isEmpty())
{JOptionPane.showMessageDialog(null, "!!!Invalid Entry BUDDY
BOY!!!" + "n"
+ " Try Again " +"n");
if (i == 3) System.exit(0);}
else
break;
}
return returnprompt;
}
public static int getNumericInput(int QN)
{boolean er;
er = false;
String tQN;
for(int i=1; i<=3; i++)
{
try{
if (QN<1 || QN>99)
{ er = true;
throw new IllegalArgumentException();
}
else
er = false;
}
catch (IllegalArgumentException e)
{
JOptionPane.showMessageDialog( null," Invalid Entry BUDDY BOY!!!
"," ERROR!!",
JOptionPane.ERROR_MESSAGE);
if (i == 3)System.exit(0);
}
PROGRAMMING 26
if (er == false)
break;
else
{tQN = JOptionPane.showInputDialog( "Please enter quantity" );
QN = Integer.parseInt(tQN);
}
}
JOptionPane.showMessageDialog(null, "Valid Quantity = " + QN);
return QN;
}
public static String VLDNO()
{String phn = null;
Pattern pattern = Pattern.compile("d{3}-s{0,1}d{3}-d{4}");
for(int i=1; i<=3; i++){
phn = JOptionPane.showInputDialog("Please Enter Phone Number in
This Format:###-###-####");
Matcher matcher = pattern.matcher(phn);
if (matcher.matches())
{JOptionPane.showMessageDialog(null, "Your Phone Number is
Valid");
break;
}
else
{JOptionPane.showMessageDialog(null,
"WRONG Format DUDE!!! Try Again!!!" + "n"
+ " This time try" + " ###-###-####"+ "n" ,
"ERROR",JOptionPane.ERROR_MESSAGE);
if (i == 3) System.exit(0);}
}
return phn;
}
private static double totalCost(int InumberItems,double costPerItem,double
taxRate)
{double Total_Cost;
Total_Cost=
PROGRAMMING 27
(InumberItems*costPerItem+InumberItems*costPerItem*taxRate);
return Total_Cost;
}
@SuppressWarnings({"CallToPrintStackTrace", "empty-statement"})
public static void main(String[] args){
String openingMsg;
String prompt,customerName,numberItems,phn,finalMessage;
String productSection, productBrand, productModel, productColor,
productSize;
int InumberItems,Quantity;
double costPerItem = 25.00,taxRate = 0.08,totalCost;
openingMsg = "Welcome to Claw Concepts"+"n"
+ "Shop for the part of your desire!";
JOptionPane.showMessageDialog(null, openingMsg);
prompt = "What's Your Name Please?";
customerName = getStringInput(prompt);
prompt = "What section would you like today? : " + "n"
+ "Cases" +"n"
+ "Mother Boards" + "n"
+ "Graphics" + "n"
+ "Monitors" + "n"
+ "Hard Drives" + "n"
+ "Processors" + "n"
+ "RAM" + "n"
+ "Optical Drives" +"n";
productSection= getStringInput(prompt);
Parts section = new Parts();
JOptionPane.showMessageDialog(null,"Section selected is = "
+ section.getSection(productSection));
prompt = "What brand will you be ordering today? : " ;
productBrand = getStringInput(prompt);
Parts parts1 = new Parts();
JOptionPane.showMessageDialog(null,"Your Brand selected is : "
PROGRAMMING 28
+ parts1.getBrand(productBrand));
prompt = "Which model would you like ? ";
productModel= getStringInput(prompt);
Parts models = new Parts();
JOptionPane.showMessageDialog(null,"Your Model selected is : "
+ models.getModel(productModel));
prompt = "What color option would you like? ";
productColor= getStringInput(prompt);
Parts colors = new Parts();
JOptionPane.showMessageDialog(null,"Your Color selected is : "
+ colors.getColor(productColor));
prompt = "Please enter Size? " + "n"
+ "If size not needed. ENTER: N/A ";
productSize = getStringInput(prompt);
Parts sizes = new Parts();
JOptionPane.showMessageDialog(null,"Your Size selected is : "
+ sizes.getSize(productSize));
prompt = "Enter desired [ Quantity ] for your order, please. ";
numberItems = getStringInput(prompt);
InumberItems = Integer.parseInt(numberItems);
Quantity = getNumericInput(InumberItems);
phn=VLDNO();
totalCost = totalCost(InumberItems,costPerItem,taxRate);
finalMessage = "Thank You For Your Order! " + customerName
+"nn"
+ "You ordered the following item: - " + productBrand + "n"
+ "ProductModel : " + productModel+ "n "
+ "ProductColor : " + productColor+ "n"
+ "ProductSize : " + productSize + "n"
+ "Quantity entered is confirmed as : " + "[ " + Quantity + " ]"
+ "nn"
+ "Your (phone nimber) is confirmed as: " + "[ " + phn + " ]"
+ "nn"
PROGRAMMING 29
+ "Tax Rate = $ " + taxRate+"%" +"n"
+ "Total Costof purchase = " + String.format("$
%.2f",totalCost)+ "nn"
+ "Your order will be shipped within 24 hours." + "n";
try{
File file = new File("order.txt");
FileWriter fileWriter;
fileWriter = new FileWriter(file);
fileWriter.write("Hello: n**** Thank You for ");
fileWriter.write("Your Order****.n");
fileWriter.write("Your Name Is: " + customerName + "n");
fileWriter.write("You ordered the following item: " + productBrand +
"n");
fileWriter.write("Your Model Is: " + productModel+ "n");
fileWriter.write("Your Color Is: " + productColor+ "n");
fileWriter.write("Your item size Is: " + productSize + "n");
fileWriter.write("Your Quantity Is: " + "[" + Quantity + "]" + "n");
fileWriter.write("Your Phone Number Is: "+ phn + "n");
fileWriter.write("Your Tax rate Is: " + taxRate + "n");
fileWriter.write("Your Total Costis: " + String.format("$
%.2f",totalCost)+ "n");
fileWriter.write("( Your order will be shipped within 24 hours.
)"+"n");
fileWriter.flush();
fileWriter.close();
}
catch (IOException e)
{e.printStackTrace();}
try {
File file = new File("order.txt");
FileReader fileReader;
fileReader = new FileReader(file);
StringBuffer stringBuffer;
stringBuffer= new StringBuffer();
int numCharsRead;
char[] charArray = new char[2048];
while ((numCharsRead = fileReader.read(charArray)) > 0) {
PROGRAMMING 30
stringBuffer.append(charArray, 0, numCharsRead);
}
fileReader.close();
System.out.println("Order Display:nn ");
System.out.println(stringBuffer.toString());
}
catch (IOException e) {
e.printStackTrace();
}
JOptionPane.showMessageDialog(null,finalMessage);
}
}
The highlighted areas represent the additional script needed to attain the functions the
program needs to attain the extra customer interaction.
The Output
In this section we will see the class parts as they have been highlighted within the script
area. When the program is started the following splash screens will begin to appear.
The “Welcome Screen”.
First, is to put you name in. If no
name is entered the next pane will
occur.
PROGRAMMING 31
This will now pop up on any of the
areas that an input is required. Forthe
purposes ofthis assignment length, I
will refrain from putting any further
“Invalid Entries”
The normal “Name” input.
This has now been added to guide the
user to the specific area for ordering
their item or product.
One more “Invalid Entry to show that
the invalid entry does work on the
new areas.
PROGRAMMING 32
We are now going to the “Case”
section.
The program validates the user’s
request for the selected area.
Now we have the brand to be ordered.
A Cooler Master case seems to be our
brand.
Here it is validated and confirmed for
order.
Next is the model, which is an ATX
High Tower. Want to fit a lot in
there.
PROGRAMMING 33
Again we have confirmation.
The color choice is black for the case.
Confirmation is again completed.
The size only comes in three sizes
MATX, ATX, or BTX so we are not
adding a number here. Just “N/A”.
It is confirmed in this splash. If
nothing were entered it WOULD
return and error.
Quantity of cases is added here. This
is where an integer is considered.
PROGRAMMING 34
Validity is confirmed here.
Again, from before, we have input the
phone number request.
It is confirmed when entered
correctly.
Here the customer receives the
accomplishment page for their order.
It exhibits all information from before
and also addresses the extra classes
added in for this feature.
PROGRAMMING 35
It also addresses the information in
the running virtual environment to
ensure everything is going to the
(file.write).
Here we see the files have been built
into the database.
When notepad is opened, all the
information presents itself to the
business to be filled.
Conclusion
The overall function of personal classes can greatly enhance the functionality of any
program being built. It’s a nice loop hole built in to create easy flowing programs that might
not already be built within the system. In a way it is like adding a few slang words to the
language vocabulary to enhance your overall communication of thought.
PROGRAMMING 36
Chapter 5 - Inheritance and Polymorphism
Arrays and Sub Classes
Last week we integrated a superclass to apply objects to our programming fields. It
introduced the “get method” to pull information from certain objects, when needed. This week’s
work has expounded on those methods as to where subclasses have been integrated into the
program and through the use of inheritance and polymorphism, these files can be called on to
perform functions within the main program. These are used to generate instances within the
program when using arrays to perform the actions. When applying all these new subclasses, I
found there were a lot of modifications needed to the main program in order for everything to
operate in a functional means. The “main static void” had to be tremendously altered to
accommodate the new functions using inheritance and polymorphism techniques. Below is a
snap shot of the added information using inheritance techniques and polymorphism techniques.
openingMsg = "Welcome to Claw Concepts"+"n"
+ "Shop for the computer of your dreams!";
JOptionPane.showMessageDialog(null, openingMsg);
prompt = "What's Your Name Please?";
customerName = getStringInput(prompt);
phn=VLDNO();
while (makeOrder.equalsIgnoreCase("yes"))
{
prompt = "What section would you like today? " + "n"
+ "Please ENTER Number Option : " + "n"
+ " ( 1 ) for Desktop Systems " + "n"
+ " ( 2 ) for Laptop Systems " + "n"
+ " ( 3 ) for Tablets " + "n";
PROGRAMMING 37
section = getStringInput(prompt);
secType= Integer.parseInt(section);
if (secType== 1){
JOptionPane.showMessageDialog(null,"Section selected is:
Desktops ");}
else if (secType== 2){
JOptionPane.showMessageDialog(null,"Brand selected is: Laptops
");}
else if (secType== 3){
JOptionPane.showMessageDialog(null,"Brand Selected is: Tablets
");
}
prompt = "What brand will you be ordering today? : " + "n"
+ " Please Enter : " + "n"
+ " ( 1 ) for Hewlett Packard " + "nn"
+ " ( 2 ) for Dell - Alienware " + "nn"
+ " ( 3 ) for Gateway - Acer " + "nn";
brand = getStringInput(prompt);
bType = Integer.parseInt(brand);
if (bType == 1){
JOptionPane.showMessageDialog(null,"Brand selected is:
HewlettPackard ");}
else if (bType == 2){
JOptionPane.showMessageDialog(null,"Brand selected is: Dell ");}
else if (bType == 3){
JOptionPane.showMessageDialog(null,"Brand Selected is: Acer
Ware ");
}
prompt = "Which model would you like ? " +"n"
+ " Please Enter : " + "n"
+ " ( 1 ) for HP Envy 810-160 " + "nn"
+ " ( 2 ) for HP Pavilion 17-e117dx " + "nn"
+ " ( 3 ) for HP 10 Plus 10.1-Inch 16 GB " + "nn"
+ " ( 4 ) for Dell OptiPlex Core i7 i7-3770 3.40 GHz mATX " +
"nn"
+ " ( 5 ) for Dell Inspiron 17R TouchscreenGaming Laptop " + "nn"
+ " ( 6 ) for Dell Venue 8 Pro 32 GB Tablet " + "nn"
PROGRAMMING 38
+ " ( 7 ) for Acer Predator AG3-605-UR2E Core i7-4770 " + "nn"
+ " ( 8 ) for Acer Aspire E5-771-378Y " + "nn"
+ " ( 9 ) for Acer Aspire Switch 10 SW5-011-18R3 " + "nn";
model = getStringInput(prompt);
mType = Integer.parseInt(model);
if (mType == 1){JOptionPane.showMessageDialog(null,
"Your selected HP Model Desktop is: HP Envy 810-160 ");
costPerItem = 329.00;}
else if (mType == 2){ JOptionPane.showMessageDialog(null,
"Your selected HP Model Laptop is: HP Pavilion 17-e117dx ");
costPerItem = 469.00;}
else if (mType == 3){JOptionPane.showMessageDialog(null,
"Your selected HP Model Tablet is: HP 10 Plus 10.1-Inch 16 GB
");
costPerItem = 229.00;}
else if (mType == 4){ JOptionPane.showMessageDialog(null,
"Your selected DellModel Desktop is: Dell OptiPlex Core i7 i7-
3770 3.40 GHz mATX ");
costPerItem = 529.00;}
else if (mType == 5){JOptionPane.showMessageDialog(null,
"Your selected Dell Model Laptop is: Dell Inspiron 17R
TouchscreenGaming Laptop ");
costPerItem = 479.00;}
else if (mType == 6){ JOptionPane.showMessageDialog(null,
"Your selected Dell Model Tablet is: Dell Venue 8 Pro 32 GB
Tablet ");
costPerItem = 139.00;}
else if (mType == 7){JOptionPane.showMessageDialog(null,
"Your selected Acer Model Desktop is: Acer Predator AG3-605-
UR2E Core i7-4770 ");
costPerItem = 429.00;}
else if (mType == 8){ JOptionPane.showMessageDialog(null,
"Your selected Acer Model Laptop is: Acer Aspire E5-771-378Y
");
costPerItem = 289.00;}
else if (mType == 9){JOptionPane.showMessageDialog(null,
"Your selected Acer Model Tablet is: Acer Aspire Switch 10
SW5-011-18R3 ");
costPerItem = 168.00;}
PROGRAMMING 39
prompt = "What color option would you like?" + "n"
+ " Please Enter : " + "n"
+ " ( 1 ) for Black " + "n"
+ " ( 2 ) for Silver " + "n"
+ " ( 3 ) for Gun Silver " + "n"
+ " ( 4 ) for Blue " + "n"
+ " ( 5 ) for Green " + "n"
+ " ( 6 ) for Red " + "n";
color = getStringInput(prompt);
cType = Integer.parseInt(color);
if (cType == 1){JOptionPane.showMessageDialog(null,
"Your selected Color is: Black ");}
else if (cType == 2){ JOptionPane.showMessageDialog(null,
"Your selected Color is: Silver ");}
else if (cType == 3){ JOptionPane.showMessageDialog(null,
"Your selected Color is: Gun Silver ");}
else if (cType == 4){ JOptionPane.showMessageDialog(null,
"Your selected Color is: Blue ");}
else if (cType == 5){ JOptionPane.showMessageDialog(null,
"Your selected Color is: Green ");}
else if (cType == 6){ JOptionPane.showMessageDialog(null,
"Your selected Color is: Red ");}
prompt = "Please enter Size? " + "n"
+ " ( 1 ) for ATX " + "nn"
+ " ( 2 ) for BTX " + "nn"
+ " ( 3 ) for 17.3 inch Laptop " + "nn"
+ " ( 4 ) for 15.3 inch Laptop " + "nn"
+ " ( 5 ) for 10.1 inch Tablet " + "nn"
+ " ( 6 ) for 9.7 inch Tablet " + "nn"
+ "If size not needed. ENTER: N/A ";
size = getStringInput(prompt);
sType = Integer.parseInt(size);
if (sType == 1){JOptionPane.showMessageDialog(null,
"Your selected Desktop Size is: ATX ");}
else if (sType== 2){ JOptionPane.showMessageDialog(null,
"Your selected Desktop Size is: BTX ");}
else if (sType== 3){ JOptionPane.showMessageDialog(null,
PROGRAMMING 40
"Your selected Laptop Size is: 17.3 inches ");}
else if (sType== 4){ JOptionPane.showMessageDialog(null,
"Your selected Laptop Size is: 15.3 inches ");}
else if (sType== 5){ JOptionPane.showMessageDialog(null,
"Your selected Tablet Size is: 10.1 inches ");}
else if (sType== 6){ JOptionPane.showMessageDialog(null,
"Your selected Tablet Size is: 9.7 inches ");}
else if (sType== 7){ JOptionPane.showMessageDialog(null,
" Size Not needed Enter: N/A ");}
Using this method, we are capable of pulling up different options verses utilizing only single
question and answer methods and it makes the process more user friendly by adding the
ability to just enter numerical values; versus having to type in all the information. However,
by completing this style, arrays do have to be added to the process so that the program can
incorporate the number sequence for the user. Thus, the script presented, to work with the
aforementioned script above will look something like this and should return multiple values
with the virtual environment when initiated. The following is the required additional script as
well as a presentation of all possible values generated when the string has been started.
String[]Section;
Section = new String[3];
String[]Brand;
Brand = new String[3];
String[]Model;
Model = new String[9];
String[]Color;
Color = new String[6];
String[]Size;
Size = new String[7];
Section[0]= "Desktops";
Section[1]= "Laptops";
Section[2]= "Tablets";
PROGRAMMING 41
Brand[0]= "Hewlett Packard";
Brand[1]= "Dell";
Brand[2]= "Acer Ware";
Model[0]="HP Envy 810-160";
Model[1]="HP Pavilion 17-e117dx";
Model[2]="HP 10 Plus 10.1-Inch 16 GB";
Model[3]="Dell OptiPlex Core i7 i7-3770 3.40 GHz";
Model[4]="Dell Inspiron 17R TouchscreenGaming Laptop";
Model[5]="Dell Venue 8 Pro 32 GB Tablet";
Model[6]="Acer Predator AG3-605-UR2E Core i7-4770";
Model[7]="Acer Aspire E5-771-378Y";
Model[8]="Acer Aspire Switch 10 SW5-011-18R3";
Color[0]="Black";
Color[1]="Silver";
Color[2]="Gun Silver";
Color[3]="Blue";
Color[4]="Green";
Color[5]="Red";
Size[0]="ATX";
Size[1]="BTX";
Size[2]="17.3 inch";
Size[3]="15.3 inch";
Size[4]="10.1 inch";
Size[5]="9.7 inch";
for (int i = 0;i <= 2;i++){
for (int j = 0;j <= 2;j++){
for (int k = 0;k <= 8;k++){
for (int m = 0;m <= 5;m++){
for (int n = 0;n <= 5;n++){
System.out.println("Section: "+Section[i]+" "+
"Brand: " +Brand[j]+" "+"Model: "+Model[k]+"
"+
"color: "+Color[m]+" "+"size: "+Size[n]);
}
}
PROGRAMMING 42
}
}
}
Section sectionTypes = new Section();
Brand brandTypes = new Brand();
Model modelTypes = new Model();
Color colorTypes = new Color();
Size sizeTypes = new Size();
After I complete the writing portion of the script noted above, I was amazed by the immensity
of the number of lines required to get a string to run with all variables. Once completed the
output on the virtual environment within the program pumped out a whopping amount of
information and possibilities as is shown below. This generated over 300 pages of
information in the output window, but for the purposes of this document, I will only be
inserting three pages to represent some of the possibilities the program presented to evaluate
customer selection. Three hundred pages was a little too much for the doc.
Virtual Output
run:
Section: Desktops Brand: Hewlett Packard Model: HP Envy 810-160 color: Black
size: ATX
Section: Desktops Brand: Hewlett Packard Model: HP Envy 810-160 color: Black
size: BTX
Section: Desktops Brand: Hewlett Packard Model: HP Envy 810-160 color: Black
size: 17.3 inch
PROGRAMMING 43
Section: Desktops Brand: Hewlett Packard Model: HP Envy 810-160 color: Black
size: 15.3 inch
Section: Desktops Brand: Hewlett Packard Model: HP Envy 810-160 color: Black
size: 10.1 inch
Section: Desktops Brand: Hewlett Packard Model: HP Envy 810-160 color: Black
size: 9.7 inch
Section: Desktops Brand: Hewlett Packard Model: HP Envy 810-160 color: Silver
size: ATX
Section: Desktops Brand: Hewlett Packard Model: HP Envy 810-160 color: Silver
size: BTX
Section: Desktops Brand: Hewlett Packard Model: HP Envy 810-160 color: Silver
size: 17.3 inch
Section: Desktops Brand: Hewlett Packard Model: HP Envy 810-160 color: Silver
size: 15.3 inch
Section: Desktops Brand: Hewlett Packard Model: HP Envy 810-160 color: Silver
size: 10.1 inch
Section: Desktops Brand: Hewlett Packard Model: HP Envy 810-160 color: Silver
size: 9.7 inch
Section: Desktops Brand: Hewlett Packard Model: HP Envy 810-160 color: Gun
Silver size: ATX
PROGRAMMING 44
Section: Desktops Brand: Hewlett Packard Model: HP Envy 810-160 color: Gun
Silver size: BTX
Section: Desktops Brand: Hewlett Packard Model: HP Envy 810-160 color: Gun
Silver size: 17.3 inch
Section: Desktops Brand: Hewlett Packard Model: HP Envy 810-160 color: Gun
Silver size: 15.3 inch
Section: Desktops Brand: Hewlett Packard Model: HP Envy 810-160 color: Gun
Silver size: 10.1 inch
Section: Desktops Brand: Hewlett Packard Model: HP Envy 810-160 color: Gun
Silver size: 9.7 inch
Section: Desktops Brand: Hewlett Packard Model: HP Envy 810-160 color: Blue
size: ATX
Section: Desktops Brand: Hewlett Packard Model: HP Envy 810-160 color: Blue
size: BTX
Section: Desktops Brand: Hewlett Packard Model: HP Envy 810-160 color: Blue
size: 17.3 inch
Section: Desktops Brand: Hewlett Packard Model: HP Envy 810-160 color: Blue
size: 15.3 inch
Section: Desktops Brand: Hewlett Packard Model: HP Envy 810-160 color: Blue
size: 10.1 inch
PROGRAMMING 45
Section: Desktops Brand: Hewlett Packard Model: HP Envy 810-160 color: Blue
size: 9.7 inch
Section: Desktops Brand: Hewlett Packard Model: HP Envy 810-160 color: Green
size: ATX
Section: Desktops Brand: Hewlett Packard Model: HP Envy 810-160 color: Green
size: BTX
Section: Desktops Brand: Hewlett Packard Model: HP Envy 810-160 color: Green
size: 17.3 inch
Section: Desktops Brand: Hewlett Packard Model: HP Envy 810-160 color: Green
size: 15.3 inch
BUILD SUCCESSFUL (total time: 9 seconds)
ScreenShots of Operation with Arrays
As the program began to run, the following screen shots appeared.
The formal welcome screen is
presented to the user.
The customer’s name is asked.
PROGRAMMING 46
The use of an appropriate number is
asked to be entered. The exception
generator is still in place in case they
make a mistake.
Once phone number is validated a valid
responseis issued.
The customer is now asked to enter a
number option for which section they
want to go to. Here, I have entered (2)
for laptops
The program now confirms the laptop
section has been selected.
The program now has for the brand that
the customer desires to look at. Again, I
have picked number 2 for Dell-Alien
ware.
PROGRAMMING 47
The program now confirms the laptop
brand has been selected.
The system now asks which model I
would like out of the Dells listed. I
picked the Dell 17R touchscreen
laptop.
It is confirmed as the Dell 17R.
Blue was my choice for a nice cover for
the laptop.
PROGRAMMING 48
The program verifies that it is blue that
has been selected.
In this frame, the customer chooses the
size of their system. The first two are
for desktops, the next two are for
laptops and the last two are for tablets.
I am choosing (3) for the 17 inch
screen.
Here, we see that option 3 is chosen
and verified for the 17 inch screen.
In this frame the customer is asked for
the quantity. I picked three laptops as I
am greedy and like laptops.
Quantity is verified for three laptops.
Hope I have enough on my credit card.
PROGRAMMING 49
The system asks me if I want to order
anything else. I think I spent enough.
Here, the final message shows the
numbers picked for my choices. It also
shows costper item, tax, and total cost
of purchase. Now I get to go out and
work so I can pay it all off.
Finally, we have the document that was sent to file in the cc-final program.
The itemized order needed to fulfill the order by the customer.
PROGRAMMING 50
Conclusion
In this phase, it was shown how to put polymorphism and inheritance into the
program to supercharge the overall capability of the program. By building a superclass,
adding methods to the superclass and inheriting additional files to pull from; we were
able to make the program more user friendly when entering the required information to
fulfill the order. The customer was now able to enter just numbers instead of having to
type or enter the required information into the system. Polymorphism and inheritance
give the program a stream lining affect for the computer, customer and programmer. It’s
a win-win situation for all parties involved.
References
There are no sources in the current document.
All entries developed by the author.

More Related Content

What's hot

Developing Java SWT Applications - A Starter
Developing Java SWT Applications - A StarterDeveloping Java SWT Applications - A Starter
Developing Java SWT Applications - A Startervcaselli
 
Servlet and jsp development with eclipse wtp
Servlet and jsp development with eclipse wtpServlet and jsp development with eclipse wtp
Servlet and jsp development with eclipse wtpodilodif
 
PVS-Studio Is Now in Chocolatey: Checking Chocolatey under Azure DevOps
PVS-Studio Is Now in Chocolatey: Checking Chocolatey under Azure DevOpsPVS-Studio Is Now in Chocolatey: Checking Chocolatey under Azure DevOps
PVS-Studio Is Now in Chocolatey: Checking Chocolatey under Azure DevOpsAndrey Karpov
 
Product! - The road to production deployment
Product! - The road to production deploymentProduct! - The road to production deployment
Product! - The road to production deploymentFilippo Zanella
 
Integrating external products into eclipse
Integrating external products into eclipseIntegrating external products into eclipse
Integrating external products into eclipseGirish Balre
 
Java 10 New Features
Java 10 New FeaturesJava 10 New Features
Java 10 New FeaturesAli BAKAN
 
JPQL/ JPA Activity 1
JPQL/ JPA Activity 1JPQL/ JPA Activity 1
JPQL/ JPA Activity 1SFI
 
Java 9 New Features
Java 9 New FeaturesJava 9 New Features
Java 9 New FeaturesAli BAKAN
 
distage: Purely Functional Staged Dependency Injection; bonus: Faking Kind Po...
distage: Purely Functional Staged Dependency Injection; bonus: Faking Kind Po...distage: Purely Functional Staged Dependency Injection; bonus: Faking Kind Po...
distage: Purely Functional Staged Dependency Injection; bonus: Faking Kind Po...7mind
 
Mockito 2.x Migration - Droidcon UK 2018
Mockito 2.x Migration - Droidcon UK 2018Mockito 2.x Migration - Droidcon UK 2018
Mockito 2.x Migration - Droidcon UK 2018Hazem Saleh
 
10 Typical Problems in Enterprise Java Applications
10 Typical Problems in Enterprise Java Applications10 Typical Problems in Enterprise Java Applications
10 Typical Problems in Enterprise Java ApplicationsEberhard Wolff
 
Architecting your GWT applications with GWT-Platform - Lesson 02
Architecting your GWT applications with GWT-Platform - Lesson 02Architecting your GWT applications with GWT-Platform - Lesson 02
Architecting your GWT applications with GWT-Platform - Lesson 02rhemsolutions
 
Checking PVS-Studio with Clang
Checking PVS-Studio with ClangChecking PVS-Studio with Clang
Checking PVS-Studio with ClangAndrey Karpov
 
Java11 New Features
Java11 New FeaturesJava11 New Features
Java11 New FeaturesHaim Michael
 
React js t1 - introduction
React js   t1 - introductionReact js   t1 - introduction
React js t1 - introductionJainul Musani
 
Features java9
Features java9Features java9
Features java9srmohan06
 
Cool JVM Tools to Help You Test
Cool JVM Tools to Help You TestCool JVM Tools to Help You Test
Cool JVM Tools to Help You TestSchalk Cronjé
 

What's hot (20)

Developing Java SWT Applications - A Starter
Developing Java SWT Applications - A StarterDeveloping Java SWT Applications - A Starter
Developing Java SWT Applications - A Starter
 
Servlet and jsp development with eclipse wtp
Servlet and jsp development with eclipse wtpServlet and jsp development with eclipse wtp
Servlet and jsp development with eclipse wtp
 
PVS-Studio Is Now in Chocolatey: Checking Chocolatey under Azure DevOps
PVS-Studio Is Now in Chocolatey: Checking Chocolatey under Azure DevOpsPVS-Studio Is Now in Chocolatey: Checking Chocolatey under Azure DevOps
PVS-Studio Is Now in Chocolatey: Checking Chocolatey under Azure DevOps
 
Product! - The road to production deployment
Product! - The road to production deploymentProduct! - The road to production deployment
Product! - The road to production deployment
 
Integrating external products into eclipse
Integrating external products into eclipseIntegrating external products into eclipse
Integrating external products into eclipse
 
Java 10 New Features
Java 10 New FeaturesJava 10 New Features
Java 10 New Features
 
Gwt portlet
Gwt portletGwt portlet
Gwt portlet
 
JPQL/ JPA Activity 1
JPQL/ JPA Activity 1JPQL/ JPA Activity 1
JPQL/ JPA Activity 1
 
Java 9 New Features
Java 9 New FeaturesJava 9 New Features
Java 9 New Features
 
distage: Purely Functional Staged Dependency Injection; bonus: Faking Kind Po...
distage: Purely Functional Staged Dependency Injection; bonus: Faking Kind Po...distage: Purely Functional Staged Dependency Injection; bonus: Faking Kind Po...
distage: Purely Functional Staged Dependency Injection; bonus: Faking Kind Po...
 
Mockito 2.x Migration - Droidcon UK 2018
Mockito 2.x Migration - Droidcon UK 2018Mockito 2.x Migration - Droidcon UK 2018
Mockito 2.x Migration - Droidcon UK 2018
 
10 Typical Problems in Enterprise Java Applications
10 Typical Problems in Enterprise Java Applications10 Typical Problems in Enterprise Java Applications
10 Typical Problems in Enterprise Java Applications
 
Architecting your GWT applications with GWT-Platform - Lesson 02
Architecting your GWT applications with GWT-Platform - Lesson 02Architecting your GWT applications with GWT-Platform - Lesson 02
Architecting your GWT applications with GWT-Platform - Lesson 02
 
Checking PVS-Studio with Clang
Checking PVS-Studio with ClangChecking PVS-Studio with Clang
Checking PVS-Studio with Clang
 
6 swt programming
6 swt programming6 swt programming
6 swt programming
 
Java 10 - Key Note
Java 10 - Key NoteJava 10 - Key Note
Java 10 - Key Note
 
Java11 New Features
Java11 New FeaturesJava11 New Features
Java11 New Features
 
React js t1 - introduction
React js   t1 - introductionReact js   t1 - introduction
React js t1 - introduction
 
Features java9
Features java9Features java9
Features java9
 
Cool JVM Tools to Help You Test
Cool JVM Tools to Help You TestCool JVM Tools to Help You Test
Cool JVM Tools to Help You Test
 

Similar to Introduction To Programming IP5

NicoleMaguire_NEES_FinalReport
NicoleMaguire_NEES_FinalReportNicoleMaguire_NEES_FinalReport
NicoleMaguire_NEES_FinalReportNicole Maguire
 
DevOps: The New Face Of Application Development - Global Azure Bootcamp
DevOps: The New Face Of Application Development - Global Azure BootcampDevOps: The New Face Of Application Development - Global Azure Bootcamp
DevOps: The New Face Of Application Development - Global Azure BootcampRichard Harbridge
 
Dive into Angular, part 5: Experience
Dive into Angular, part 5: ExperienceDive into Angular, part 5: Experience
Dive into Angular, part 5: ExperienceOleksii Prohonnyi
 
Tutorial ranorex
Tutorial ranorexTutorial ranorex
Tutorial ranorexradikalzen
 
Understanding Framework Architecture using Eclipse
Understanding Framework Architecture using EclipseUnderstanding Framework Architecture using Eclipse
Understanding Framework Architecture using Eclipseanshunjain
 
Coldbox developer training – session 4
Coldbox developer training – session 4Coldbox developer training – session 4
Coldbox developer training – session 4Billie Berzinskas
 
Tutorial storybook
Tutorial storybookTutorial storybook
Tutorial storybookVinay H G
 
Spring Performance Gains
Spring Performance GainsSpring Performance Gains
Spring Performance GainsVMware Tanzu
 
SMI - Introduction to Java
SMI - Introduction to JavaSMI - Introduction to Java
SMI - Introduction to JavaSMIJava
 
Release with confidence
Release with confidenceRelease with confidence
Release with confidenceJohn Congdon
 
Unit Testing in Flutter - From Workflow Essentials to Complex Scenarios
Unit Testing in Flutter - From Workflow Essentials to Complex ScenariosUnit Testing in Flutter - From Workflow Essentials to Complex Scenarios
Unit Testing in Flutter - From Workflow Essentials to Complex ScenariosFlutter Agency
 
Testing in FrontEnd World by Nikita Galkin
Testing in FrontEnd World by Nikita GalkinTesting in FrontEnd World by Nikita Galkin
Testing in FrontEnd World by Nikita GalkinSigma Software
 
Никита Галкин "Testing in Frontend World"
Никита Галкин "Testing in Frontend World"Никита Галкин "Testing in Frontend World"
Никита Галкин "Testing in Frontend World"Fwdays
 
Architecting Single Activity Applications (With or Without Fragments)
Architecting Single Activity Applications (With or Without Fragments)Architecting Single Activity Applications (With or Without Fragments)
Architecting Single Activity Applications (With or Without Fragments)Gabor Varadi
 
Adding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsAdding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsJeff Durta
 
Front End performance as a Continuous Integration - Part1
Front End performance as a Continuous Integration - Part1Front End performance as a Continuous Integration - Part1
Front End performance as a Continuous Integration - Part1Tarence DSouza
 
The State of the Veil Framework
The State of the Veil FrameworkThe State of the Veil Framework
The State of the Veil FrameworkVeilFramework
 

Similar to Introduction To Programming IP5 (20)

NicoleMaguire_NEES_FinalReport
NicoleMaguire_NEES_FinalReportNicoleMaguire_NEES_FinalReport
NicoleMaguire_NEES_FinalReport
 
Ase02.ppt
Ase02.pptAse02.ppt
Ase02.ppt
 
DevOps: The New Face Of Application Development - Global Azure Bootcamp
DevOps: The New Face Of Application Development - Global Azure BootcampDevOps: The New Face Of Application Development - Global Azure Bootcamp
DevOps: The New Face Of Application Development - Global Azure Bootcamp
 
Dive into Angular, part 5: Experience
Dive into Angular, part 5: ExperienceDive into Angular, part 5: Experience
Dive into Angular, part 5: Experience
 
java
javajava
java
 
Tutorial ranorex
Tutorial ranorexTutorial ranorex
Tutorial ranorex
 
Understanding Framework Architecture using Eclipse
Understanding Framework Architecture using EclipseUnderstanding Framework Architecture using Eclipse
Understanding Framework Architecture using Eclipse
 
Coldbox developer training – session 4
Coldbox developer training – session 4Coldbox developer training – session 4
Coldbox developer training – session 4
 
Tutorial storybook
Tutorial storybookTutorial storybook
Tutorial storybook
 
Spring Performance Gains
Spring Performance GainsSpring Performance Gains
Spring Performance Gains
 
SMI - Introduction to Java
SMI - Introduction to JavaSMI - Introduction to Java
SMI - Introduction to Java
 
Release with confidence
Release with confidenceRelease with confidence
Release with confidence
 
Unit Testing in Flutter - From Workflow Essentials to Complex Scenarios
Unit Testing in Flutter - From Workflow Essentials to Complex ScenariosUnit Testing in Flutter - From Workflow Essentials to Complex Scenarios
Unit Testing in Flutter - From Workflow Essentials to Complex Scenarios
 
Testing in FrontEnd World by Nikita Galkin
Testing in FrontEnd World by Nikita GalkinTesting in FrontEnd World by Nikita Galkin
Testing in FrontEnd World by Nikita Galkin
 
Никита Галкин "Testing in Frontend World"
Никита Галкин "Testing in Frontend World"Никита Галкин "Testing in Frontend World"
Никита Галкин "Testing in Frontend World"
 
Architecting Single Activity Applications (With or Without Fragments)
Architecting Single Activity Applications (With or Without Fragments)Architecting Single Activity Applications (With or Without Fragments)
Architecting Single Activity Applications (With or Without Fragments)
 
Adding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsAdding a modern twist to legacy web applications
Adding a modern twist to legacy web applications
 
Qa process
Qa processQa process
Qa process
 
Front End performance as a Continuous Integration - Part1
Front End performance as a Continuous Integration - Part1Front End performance as a Continuous Integration - Part1
Front End performance as a Continuous Integration - Part1
 
The State of the Veil Framework
The State of the Veil FrameworkThe State of the Veil Framework
The State of the Veil Framework
 

More from Mark Simon

CSS-454 information Security Assurance CAPSTONE
CSS-454 information Security Assurance CAPSTONECSS-454 information Security Assurance CAPSTONE
CSS-454 information Security Assurance CAPSTONEMark Simon
 
City Hall Network Project
City Hall Network ProjectCity Hall Network Project
City Hall Network ProjectMark Simon
 
IT-106 Pseudo-Coding Wk 5
IT-106 Pseudo-Coding Wk 5IT-106 Pseudo-Coding Wk 5
IT-106 Pseudo-Coding Wk 5Mark Simon
 
Discrete Math IP4 - Automata Theory
Discrete Math IP4 - Automata TheoryDiscrete Math IP4 - Automata Theory
Discrete Math IP4 - Automata TheoryMark Simon
 
Phase 3 IP Discrete Mathematics - Vertexes & Hierarchical Trees
Phase 3 IP Discrete Mathematics - Vertexes & Hierarchical TreesPhase 3 IP Discrete Mathematics - Vertexes & Hierarchical Trees
Phase 3 IP Discrete Mathematics - Vertexes & Hierarchical TreesMark Simon
 
Discrete Mathematics - Matrices & Matrix IP2
Discrete Mathematics - Matrices & Matrix IP2Discrete Mathematics - Matrices & Matrix IP2
Discrete Mathematics - Matrices & Matrix IP2Mark Simon
 
ENG101- Week 5 Individual Project
ENG101- Week 5 Individual ProjectENG101- Week 5 Individual Project
ENG101- Week 5 Individual ProjectMark Simon
 
Mark Simon IT 245 Introduction to Network Management
Mark Simon IT 245 Introduction to Network ManagementMark Simon IT 245 Introduction to Network Management
Mark Simon IT 245 Introduction to Network ManagementMark Simon
 
Greenhouse Effect IP3
Greenhouse Effect IP3Greenhouse Effect IP3
Greenhouse Effect IP3Mark Simon
 
Materials, Semi-conductors and Micro-Chips
Materials, Semi-conductors and Micro-ChipsMaterials, Semi-conductors and Micro-Chips
Materials, Semi-conductors and Micro-ChipsMark Simon
 
What you eat phase 1
What you eat   phase 1What you eat   phase 1
What you eat phase 1Mark Simon
 
Ip 5 discrete mathematics
Ip 5 discrete mathematicsIp 5 discrete mathematics
Ip 5 discrete mathematicsMark Simon
 

More from Mark Simon (13)

CSS-454 information Security Assurance CAPSTONE
CSS-454 information Security Assurance CAPSTONECSS-454 information Security Assurance CAPSTONE
CSS-454 information Security Assurance CAPSTONE
 
City Hall Network Project
City Hall Network ProjectCity Hall Network Project
City Hall Network Project
 
IT-106 Pseudo-Coding Wk 5
IT-106 Pseudo-Coding Wk 5IT-106 Pseudo-Coding Wk 5
IT-106 Pseudo-Coding Wk 5
 
Discrete Math IP4 - Automata Theory
Discrete Math IP4 - Automata TheoryDiscrete Math IP4 - Automata Theory
Discrete Math IP4 - Automata Theory
 
Phase 3 IP Discrete Mathematics - Vertexes & Hierarchical Trees
Phase 3 IP Discrete Mathematics - Vertexes & Hierarchical TreesPhase 3 IP Discrete Mathematics - Vertexes & Hierarchical Trees
Phase 3 IP Discrete Mathematics - Vertexes & Hierarchical Trees
 
Discrete Mathematics - Matrices & Matrix IP2
Discrete Mathematics - Matrices & Matrix IP2Discrete Mathematics - Matrices & Matrix IP2
Discrete Mathematics - Matrices & Matrix IP2
 
Phase 1 ip
Phase 1 ipPhase 1 ip
Phase 1 ip
 
ENG101- Week 5 Individual Project
ENG101- Week 5 Individual ProjectENG101- Week 5 Individual Project
ENG101- Week 5 Individual Project
 
Mark Simon IT 245 Introduction to Network Management
Mark Simon IT 245 Introduction to Network ManagementMark Simon IT 245 Introduction to Network Management
Mark Simon IT 245 Introduction to Network Management
 
Greenhouse Effect IP3
Greenhouse Effect IP3Greenhouse Effect IP3
Greenhouse Effect IP3
 
Materials, Semi-conductors and Micro-Chips
Materials, Semi-conductors and Micro-ChipsMaterials, Semi-conductors and Micro-Chips
Materials, Semi-conductors and Micro-Chips
 
What you eat phase 1
What you eat   phase 1What you eat   phase 1
What you eat phase 1
 
Ip 5 discrete mathematics
Ip 5 discrete mathematicsIp 5 discrete mathematics
Ip 5 discrete mathematics
 

Recently uploaded

Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendArshad QA
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfCionsystems
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 

Recently uploaded (20)

Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and Backend
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdf
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 

Introduction To Programming IP5

  • 1. Mark L. Simon II Individual Project / IP 1 thru 5 IT110 -1404A-01 Introduction to Programming Professor: Mazen Alkhatib 10 November, 2014 Colorado Technical University
  • 2. PROGRAMMING 2 Table of Contents Chapter One – Fundmentals............................................................................................................ 3 Overview..................................................................................................................................... 3 Java Fundamentals ...................................................................................................................... 4 Re-Factored Java Code ............................................................................................................... 4 Java Runtime Environment......................................................................................................... 6 Conclusion .................................................................................................................................. 8 Chapter 2 - Java Control Structures ................................................................................................ 9 Control Structures ....................................................................................................................... 9 Script for Method........................................................................................................................ 9 Splash Pages for Program ......................................................................................................... 11 Conclusion ................................................................................................................................ 13 Chapter 3 - Error Handling and File Input or Output ................................................................... 14 Errors and Exceptions ............................................................................................................... 14 Script for Input / Output, Error and Exception Handling ......................................................... 15 Conclusion ................................................................................................................................ 22 Chapter 4 - Object-Oriented Techniques ...................................................................................... 23 Object-Orientated Class Script.................................................................................................. 24 The Output ................................................................................................................................ 30 Conclusion ................................................................................................................................ 35 Chapter 5 - Inheritance and Polymorphism .................................................................................. 36 Arrays and Sub Classes............................................................................................................. 36 Virtual Output ........................................................................................................................... 42 Screen Shots of Operation with Arrays ........................................................................................ 45 Conclusion ................................................................................................................................ 50 References..................................................................................................................................... 50
  • 3. PROGRAMMING 3 Programing IT110 Chapter One – Fundmentals Overview Welcome to the world of beginners programming where you can lose your mind crunching the script or letting the developer program do it for you. In this phase, I was given a few lines of script to design my own opening statement or splash page on a web site. My website entails selling computer hardware components at reduced prices. The primary purpose of this website welcome splash is to aid homeowners in getting items for their computers without paying the exorbitant prices normally seen with computer building. In the website the customer has the choice of various components to choose from. There will be mobos, processors, heat sinks, RAM, graphics cards, hard drives, cases, and monitors. In a use case scenario the graph will look as seen below in figure1-1. (Figure 1-1)
  • 4. PROGRAMMING 4 Java Fundamentals I had a decision to make and that decision was weather Eclipse or NetBeans would be used to formulate this program. I initiated Eclipse and tried integrating everything into one program. I quickly found that Eclipse was not very user friendly for the first time user. It would tell me what was wrong, but wasn’t able to quickly rectify mistakes for me, or seem to want to debug each of the steps responsible for the script halting and giving errors. I threw the file all out, shut down Eclipse and started the NetBeans console. This program easily started a new page, could quickly integrate the PizzaRUS.java file in without delay and it was easy to do the fundamental integration. Once they were both on the NetBeans board, the console quickly told me the problems; where they were at, and possibilities for fixes by the quick click of a button. Once the debugger was run and the j-options problem was worked, it all came together to run and create the windows pop-ups needed for introduction. Below is the refactored code, which made it all happen. Re-Factored Java Code /*IT110-1404A-01 (Introduction to Programming) * Claw Concepts Phase 1 IP * Created on 10/09/14 by Mark L. Simon II * Instructor : Mazen Alkhatib */ package ClawConceptsPhase1; import javax.swing.JOptionPane; /** * * @author Mark Simon */ public class Claw_Concepts {
  • 5. PROGRAMMING 5 public static void main(String[] args){ // declare variables String openingMsg, nameInputMsg, customerName, nameOutputMsg, returnInputMsg, customerReturn, returnOutputMsg, greetingOutputMsg, outputMsg; // display opening message openingMsg = "*** Welcome to Claw Concepts Ordering System ***n" + " Shop for the part you desire!"; JOptionPane.showMessageDialog(null, openingMsg); // get required input using dialogs nameInputMsg = "Please enter your name: "; customerName = JOptionPane.showInputDialog(nameInputMsg); returnInputMsg = "Are you a returning customer (yes or no)? "; customerReturn = JOptionPane.showInputDialog(returnInputMsg); // build output strings nameOutputMsg = "Welcome " + customerName + ".nn"; returnOutputMsg = "Your return customer status is " + customerReturn + ".n"; greetingOutputMsg = "Thank you for visiting Claw Concepts!" + "nn" + "Your order will be shipped within the next 24 hours.n"; // create and display output string outputMsg = nameOutputMsg + returnOutputMsg + greetingOutputMsg; JOptionPane.showMessageDialog(null, outputMsg); System.exit(0); } // end main() } // end class ClawConceptsPhase1 (Figure 1-2)
  • 6. PROGRAMMING 6 Java Runtime Environment As I ran the program the following windows started popping up. I placed the required information into each of the windows to ensure it would take the information and change to the next function and then ran it again without placing information in to the boxes. The program still sequenced through the motions and then ended the function. (Figure 1-3) As we see above on (figure 1-3), the first splash screen represents “Claw Concepts Ordering System”. As soon as “OK” is hit the next splash screen appears, as is seen in (figure 1-4). (Figure 1-4)
  • 7. PROGRAMMING 7 As we see in (figure 1-4), I am able to easily place my name in the box for temporary verification of customer. Once the “OK button is clicked the next splash window pops up as is seen in (figure 1-5). (Figure 1-5) In figure 1-5 it represents the question to the customer if they are a reoccurring customer. I have typed “Yes I am” in the box to see if it will annotate the process. Once this is done, I hit the “OK” button to move on through the program. What is observed next is in (figure 1-6). (Figure 1-6)
  • 8. PROGRAMMING 8 As we can see in (figure 1-6), my name and the customer status have exactly what I entered into the prior boxes. The run test is now complete. Conclusion For the phase one assignment we were asked to integrate a program into Java NetBeans or Eclipse to make it a splash screen questionnaire for our web site. Mine was exhibited as “Claw Concepts” and integrated into a form of Java pseudocode with the steps needed to execute the program. Upon completion of the program and pulling out un-needed lines of script, the file was capable of initiating and presenting screen shots of its execution. Refactoring was a key concept in ensuring proper function and execution of the program, with the help of the debugging tools within the program. In the end all functions executed for the needed operation.
  • 9. PROGRAMMING 9 Chapter 2 - Java Control Structures Control Structures Control structures are the very essence of what makes a Java program run without sequentially stating each line within a given program. By using decision making statements, control statements, looping statements, branching statements, break statements, and return statements; a program can choose which parameters are needed given the equation it’s chewing on. In this portion of the individual project, we have taken the opening “JOptionPane” area and integrated it with the “getStringInput” scenarios within the JOptionPane program. The result of this incorporation is to output direct customer needs based on the input from the customer. This is then all displayed within the splash panes. As we see below (Figure 2-1), the initial program was scribed into the (CC Method) script. (Figure 2-1) Script for Method import javax.swing.JOptionPane; public class CC_method_review{ private static String getStringInput(String prompt) { String returnprompt=null; for (int i =1; i <= 3; i++) {returnprompt = JOptionPane.showInputDialog(prompt); if(returnprompt.isEmpty()) {JOptionPane.showMessageDialog(null, "Invalid Entry!!"); if (i == 3) System.exit(0); } else break; }
  • 10. PROGRAMMING 10 return returnprompt; } private static double totalCost(int InumberItems, double costPerItem, double discount, double taxRate) {double Total_Cost; Total_Cost= (InumberItems*costPerItem- InumberItems*costPerItem*discount +InumberItems*costPerItem*taxRate); return Total_Cost; } public static void main(String[] args){ String openingMsg; String prompt,customerName,customerReturn,numberItems,modelType; int InumberItems; double costPerItem= 25.00,discount = 0.05,taxRate = 0.08,totalCost ; openingMsg = "Welcome to Claw Concepts"+"n" + "Shop for the part of your desire!"; JOptionPane.showMessageDialog(null, openingMsg); prompt = "What's Your Name Please?"; customerName = getStringInput(prompt); prompt = "Are you a returning Customer?" + "n" + "Please Enter (Yes or No)"; customerReturn = getStringInput(prompt); prompt = "How many CD Players would you like?"; numberItems = getStringInput(prompt); InumberItems = Integer.parseInt(numberItems); prompt = " Which Brand would you like? " + "n" + " Please Enter Model " + "n"; modelType = getStringInput(prompt);
  • 11. PROGRAMMING 11 totalCost = totalCost(InumberItems,costPerItem,discount,taxRate); JOptionPane.showMessageDialog(null,"Thank You ForYour Order! " + " Mr. "+ customerName + "n" + "Your Return Status is = " +customerReturn+ "n" + "Model Ordered is = " + modelType + "n" + "Discount = " + discount+"%" +"n" + "Tax Rate = $" + taxRate+"%" +"n" + "TotalCost= $"+ totalCost +" n" + "Your order will be shipped in 24 hours"+"n"); } } Splash Pages for Program Once this program is run the following results were returned. Missed type-in one time With Name Entered Next Run yes/ no with nothing entered. Return with Invalid Entry.
  • 12. PROGRAMMING 12 Run with Info Entered . Program continues on. How many CD’s with no entry. Returns the following “Invalid Entry” With CD Amount entered continues on. Returns the next splash frame. When nothing is entered for brand/model.
  • 13. PROGRAMMING 13 Now with the brand/model entered. The final outcomes after all entries are completed. Conclusion As has been seen, once the “JOptionPane” is integrated with the “getStringInput” and then couple with the “showMessageDialog”, we can produce a program with loops, input and output to work with customers on a web page.
  • 14. PROGRAMMING 14 Chapter 3 - Error Handling and File Input or Output Errors and Exceptions Errors are the formidable adversary to any programmers operation. If one period, semi- colon or any other character is missed or out of sequence, it can mean hours of back tracking to find this program stopper. Most functions within the program start with identifying variables. These are then computed into the main function of the program and a final output is returned using the display options. Seems quite simple, but as these functions start to rely on one another for progression of the program, road bumps and pot holes will occur, especially if one variable is not recognized within another function or sub routine of the program. This is where error handling tool steps into action and lets the programmer know that a certain line of script will not function until these errors are dealt with. During this phase, it has been noted that error handling is paramount to the programs capability of running properly. A built in error handling tool could be called like the Input/output Exception handler. This may be inserted to a function to create an exception for the routine, if it is found not to be true under the Boolean concept or other function. It’s an easy way for the function to be cleared and an error averted if it doesn’t come out with the correct outcome. The exception handler can do the job, but it must be written correctly or this function can end up being part of the known errors. Listed below is this week’s script for showing error situation and how exception handlers divert problem areas from throwing errors. Now it just throws exceptions and evaluates it instead of throwing an immediate error. Review in fig 3-1.
  • 15. PROGRAMMING 15 Script for Input / Output, Error and Exception Handling ( Fig 3-1 ) package CC_input_output; /*IT110-1404A-01 (Introduction to Programming) * Claw Concepts Phase 3 IP * Created on 10/21/14 by Mark L. Simon II * Instructor : Mazen Alkhatib */ import java.io.File; import java.io.FileWriter; import java.io.FileReader; import java.io.IOException; import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.swing.JOptionPane; /** * @author Mark */ public class cc_input_output{ private static String getStringInput(String prompt) {String returnprompt = null; for (int i =1; i <= 3; i++) {returnprompt = JOptionPane.showInputDialog(prompt); if(returnprompt.isEmpty()) {JOptionPane.showMessageDialog(null, "!!!Invalid Entry BUDDY BOY!!!" + "n" + " Try Again " +"n"); if (i == 3) System.exit(0);} else break; } return returnprompt; } public static int getNumericInput(int QN) {boolean er; er = false; String tQN; for(int i=1; i<=3; i++) { try{
  • 16. PROGRAMMING 16 if (QN<1 || QN>99) { er = true; throw new IllegalArgumentException(); } else er = false; } catch (IllegalArgumentException e) { JOptionPane.showMessageDialog( null," Invalid Entry BUDDY BOY!!! "," ERROR!!", JOptionPane.ERROR_MESSAGE); if (i == 3)System.exit(0); } if (er == false) break; else {tQN = JOptionPane.showInputDialog( "Please enter quantity" ); QN = Integer.parseInt(tQN); } } JOptionPane.showMessageDialog(null, "Valid Quantity = " + QN); return QN; } public static String VLDNO() {String phn = null; Pattern pattern = Pattern.compile("d{3}-s{0,1}d{3}-d{4}"); for(int i=1; i<=3; i++){ phn = JOptionPane.showInputDialog("Please Enter Phone Number in This Format:###-###-####"); Matcher matcher = pattern.matcher(phn); if (matcher.matches()) {JOptionPane.showMessageDialog(null, "Your Phone Number is Valid"); break; } else {JOptionPane.showMessageDialog(null, "WRONG Format DUDE!!! Try Again!!!" + "n" + " This time try" + " ###-###-####" + "n" , "ERROR",JOptionPane.ERROR_MESSAGE); if (i == 3) System.exit(0);} } return phn;
  • 17. PROGRAMMING 17 } private static double totalCost(int InumberItems,double costPerItem, double taxRate) {double Total_Cost; Total_Cost = (InumberItems*costPerItem+InumberItems*costPerItem*taxRate); return Total_Cost; } @SuppressWarnings({"CallToPrintStackTrace", "empty-statement"}) public static void main(String[] args){ String openingMsg; String prompt,customerName,numberItems,phn,finalMessage; int InumberItems,Quantity; double costPerItem = 5.00,taxRate = 0.08,totalCost; openingMsg = "Welcome to Claw Concepts"+"n" + "Shop for the part of your desire!"; JOptionPane.showMessageDialog(null, openingMsg); prompt = "What's Your Name Please?"; customerName = getStringInput(prompt); prompt = "How many componets would you like?"; numberItems = getStringInput(prompt); InumberItems = Integer.parseInt(numberItems); Quantity = getNumericInput(InumberItems); phn=VLDNO(); totalCost = totalCost(Quantity,costPerItem,taxRate); finalMessage = "Thank You For Your Order! " + customerName +"nn" + "Quantity entered is confirmed as: " + "[ " + Quantity + " ]" + "nn" + "Your (phone nimber) is confirmed as: " + "[" + phn + "]" + "nn" + "Tax Rate = $ " + taxRate+"%" +"n" + "Total Cost of purchase = " + String.format("$ %.2f",totalCost) + "nn" + "Your order will be shipped within 24 hours." + "n"; try{ File file = new File("order.txt");
  • 18. PROGRAMMING 18 FileWriter fileWriter; fileWriter = new FileWriter(file); fileWriter.write("Hello: n**************** Thank You for "); fileWriter.write("Your Order****************.n"); fileWriter.write("Your Name Is: " + customerName + "n"); fileWriter.write("Your Quantity Is: "+"[" + Quantity + "]" + "n"); fileWriter.write("Your Phone Number Is: "+ phn + "n"); fileWriter.write("Your Tax rate Is: " + taxRate + "n"); fileWriter.write("Your Total Cost is: " + String.format("$ %.2f",totalCost) + "n"); fileWriter.write("( Your order will be shipped within 24 hours. )"+"n"); fileWriter.flush(); fileWriter.close(); } catch (IOException e) {e.printStackTrace();} try { File file = new File("order.txt"); FileReader fileReader; fileReader = new FileReader(file); StringBuffer stringBuffer; stringBuffer= new StringBuffer(); int numCharsRead; char[] charArray = new char[2048]; while ((numCharsRead = fileReader.read(charArray)) > 0) { stringBuffer.append(charArray, 0, numCharsRead); } fileReader.close(); System.out.println("Order Display:nn "); System.out.println(stringBuffer.toString()); } catch (IOException e) { e.printStackTrace(); } JOptionPane.showMessageDialog(null,finalMessage); } } As we see above. There can be many areas where errors may pop up in the Try / Catch areas, but it also develops the exception to handle a possible error of the function. Below is what is observed when everything runs as planned.
  • 19. PROGRAMMING 19 When the program is started we will see the following panes. Here is the starting splash page. It purports to what we have done in the method area from before. The next splash pane asks for the name. What if we hit the key before putting in our name? The program happily tells good ole BUDDY BOY that the input is incorrect and the user needs to try it again This time with the name entered, we will get the response in the next frame. Okay…we are on to the next frame. Here too, if the information is entered incorrectly, a warning will pop up as described in the next
  • 20. PROGRAMMING 20 frame. It’s the same error as the name, but this time if no entry, the number “0” or anything above “99 is entered, it will come back as an Error. Here, there was nothing entered. In this frame a number was entered, but it was outside the (1 through 99) range of the proper selection parameter. Once a proper number, from (1 to 99) is entered the next screen will appear. Now we have a valid quantity and the program moves on. Now the phone number is needed. If it is put in wrong or nothing at all, the following message will occur.
  • 21. PROGRAMMING 21 The DUDE is at it again. All thumbs and no fingers and accidently his the return before entering the phone number. Now the number is entered properly. This should return proper valid compliance in the next frame. If we look back at the script, we can see this as the last input function before the program rights it all to file and the generates a text document In the package area, we can see that it has built an order.txt file saying that it has been written to a file. Within the file is the order information needed to fill the order As you are nor reading this, so is the customer, on the return splash pane below.
  • 22. PROGRAMMING 22 This is what the customer will see when they are complete on their order. Conclusion Error checking takes on many forms. Weather it is the lines of code or in the function that is being run. The error and exception handlers are always ensuring everything has to be entered in a specific way. This is to ensure proper flawless operation of the program and the data entered into the program. As has been stated through this phase, error and exception handling are great tools to ensure accuracy of outcome but it’s wise to keep discernment when deploying their usages.
  • 23. PROGRAMMING 23 Chapter 4 - Object-OrientedTechniques //CC Classes [Claw Online Ordering | Department:String |Brand:string; Model:String; Color:String;Size:String|getDepartment();getBrand();getModel();getColor()get Size (Figure 4-1) If we want to add our own classes, also known as “Object-Orientated Design”, we have to create a class diagram to represent the intended idea for our program. Above, in (figure 4- 1), a representation of the intended classes is illustrated to be able to formulate a structure for the given idea of the classes to be represented. This is then applied to the script to attain a functional class system within the program. As is represented below (Figure 4-2), the class section is designated at the top of the programming. To initiate the various classes entered within the program. Let’s take a look the script to evaluate how this all works.
  • 24. PROGRAMMING 24 Object-Orientated Class Script (Figure 4-2) /*IT110-1404A-01 (Introduction to Programming) * Claw Concepts Phase3 IP * Created on 10/21/14 by Mark L. Simon II * Instructor : Mazen Alkhatib */ import java.io.File; import java.io.FileWriter; import java.io.FileReader; import java.io.IOException; import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.swing.JOptionPane; /** * @author Mark */ class Parts{ String Brand,model,color,size; String getSection(String Section){ return Section;} String getBrand(String Brand){ return Brand;} String getModel(String Model){ return Model;} String getColor(String Color){ return Color;} String getSize(String Size){ {return Size;} } }
  • 25. PROGRAMMING 25 public class claw_classes{ private static String getStringInput(String prompt) {String returnprompt = null; for (int i =1; i <= 3; i++) {returnprompt = JOptionPane.showInputDialog(prompt); if(returnprompt.isEmpty()) {JOptionPane.showMessageDialog(null, "!!!Invalid Entry BUDDY BOY!!!" + "n" + " Try Again " +"n"); if (i == 3) System.exit(0);} else break; } return returnprompt; } public static int getNumericInput(int QN) {boolean er; er = false; String tQN; for(int i=1; i<=3; i++) { try{ if (QN<1 || QN>99) { er = true; throw new IllegalArgumentException(); } else er = false; } catch (IllegalArgumentException e) { JOptionPane.showMessageDialog( null," Invalid Entry BUDDY BOY!!! "," ERROR!!", JOptionPane.ERROR_MESSAGE); if (i == 3)System.exit(0); }
  • 26. PROGRAMMING 26 if (er == false) break; else {tQN = JOptionPane.showInputDialog( "Please enter quantity" ); QN = Integer.parseInt(tQN); } } JOptionPane.showMessageDialog(null, "Valid Quantity = " + QN); return QN; } public static String VLDNO() {String phn = null; Pattern pattern = Pattern.compile("d{3}-s{0,1}d{3}-d{4}"); for(int i=1; i<=3; i++){ phn = JOptionPane.showInputDialog("Please Enter Phone Number in This Format:###-###-####"); Matcher matcher = pattern.matcher(phn); if (matcher.matches()) {JOptionPane.showMessageDialog(null, "Your Phone Number is Valid"); break; } else {JOptionPane.showMessageDialog(null, "WRONG Format DUDE!!! Try Again!!!" + "n" + " This time try" + " ###-###-####"+ "n" , "ERROR",JOptionPane.ERROR_MESSAGE); if (i == 3) System.exit(0);} } return phn; } private static double totalCost(int InumberItems,double costPerItem,double taxRate) {double Total_Cost; Total_Cost=
  • 27. PROGRAMMING 27 (InumberItems*costPerItem+InumberItems*costPerItem*taxRate); return Total_Cost; } @SuppressWarnings({"CallToPrintStackTrace", "empty-statement"}) public static void main(String[] args){ String openingMsg; String prompt,customerName,numberItems,phn,finalMessage; String productSection, productBrand, productModel, productColor, productSize; int InumberItems,Quantity; double costPerItem = 25.00,taxRate = 0.08,totalCost; openingMsg = "Welcome to Claw Concepts"+"n" + "Shop for the part of your desire!"; JOptionPane.showMessageDialog(null, openingMsg); prompt = "What's Your Name Please?"; customerName = getStringInput(prompt); prompt = "What section would you like today? : " + "n" + "Cases" +"n" + "Mother Boards" + "n" + "Graphics" + "n" + "Monitors" + "n" + "Hard Drives" + "n" + "Processors" + "n" + "RAM" + "n" + "Optical Drives" +"n"; productSection= getStringInput(prompt); Parts section = new Parts(); JOptionPane.showMessageDialog(null,"Section selected is = " + section.getSection(productSection)); prompt = "What brand will you be ordering today? : " ; productBrand = getStringInput(prompt); Parts parts1 = new Parts(); JOptionPane.showMessageDialog(null,"Your Brand selected is : "
  • 28. PROGRAMMING 28 + parts1.getBrand(productBrand)); prompt = "Which model would you like ? "; productModel= getStringInput(prompt); Parts models = new Parts(); JOptionPane.showMessageDialog(null,"Your Model selected is : " + models.getModel(productModel)); prompt = "What color option would you like? "; productColor= getStringInput(prompt); Parts colors = new Parts(); JOptionPane.showMessageDialog(null,"Your Color selected is : " + colors.getColor(productColor)); prompt = "Please enter Size? " + "n" + "If size not needed. ENTER: N/A "; productSize = getStringInput(prompt); Parts sizes = new Parts(); JOptionPane.showMessageDialog(null,"Your Size selected is : " + sizes.getSize(productSize)); prompt = "Enter desired [ Quantity ] for your order, please. "; numberItems = getStringInput(prompt); InumberItems = Integer.parseInt(numberItems); Quantity = getNumericInput(InumberItems); phn=VLDNO(); totalCost = totalCost(InumberItems,costPerItem,taxRate); finalMessage = "Thank You For Your Order! " + customerName +"nn" + "You ordered the following item: - " + productBrand + "n" + "ProductModel : " + productModel+ "n " + "ProductColor : " + productColor+ "n" + "ProductSize : " + productSize + "n" + "Quantity entered is confirmed as : " + "[ " + Quantity + " ]" + "nn" + "Your (phone nimber) is confirmed as: " + "[ " + phn + " ]" + "nn"
  • 29. PROGRAMMING 29 + "Tax Rate = $ " + taxRate+"%" +"n" + "Total Costof purchase = " + String.format("$ %.2f",totalCost)+ "nn" + "Your order will be shipped within 24 hours." + "n"; try{ File file = new File("order.txt"); FileWriter fileWriter; fileWriter = new FileWriter(file); fileWriter.write("Hello: n**** Thank You for "); fileWriter.write("Your Order****.n"); fileWriter.write("Your Name Is: " + customerName + "n"); fileWriter.write("You ordered the following item: " + productBrand + "n"); fileWriter.write("Your Model Is: " + productModel+ "n"); fileWriter.write("Your Color Is: " + productColor+ "n"); fileWriter.write("Your item size Is: " + productSize + "n"); fileWriter.write("Your Quantity Is: " + "[" + Quantity + "]" + "n"); fileWriter.write("Your Phone Number Is: "+ phn + "n"); fileWriter.write("Your Tax rate Is: " + taxRate + "n"); fileWriter.write("Your Total Costis: " + String.format("$ %.2f",totalCost)+ "n"); fileWriter.write("( Your order will be shipped within 24 hours. )"+"n"); fileWriter.flush(); fileWriter.close(); } catch (IOException e) {e.printStackTrace();} try { File file = new File("order.txt"); FileReader fileReader; fileReader = new FileReader(file); StringBuffer stringBuffer; stringBuffer= new StringBuffer(); int numCharsRead; char[] charArray = new char[2048]; while ((numCharsRead = fileReader.read(charArray)) > 0) {
  • 30. PROGRAMMING 30 stringBuffer.append(charArray, 0, numCharsRead); } fileReader.close(); System.out.println("Order Display:nn "); System.out.println(stringBuffer.toString()); } catch (IOException e) { e.printStackTrace(); } JOptionPane.showMessageDialog(null,finalMessage); } } The highlighted areas represent the additional script needed to attain the functions the program needs to attain the extra customer interaction. The Output In this section we will see the class parts as they have been highlighted within the script area. When the program is started the following splash screens will begin to appear. The “Welcome Screen”. First, is to put you name in. If no name is entered the next pane will occur.
  • 31. PROGRAMMING 31 This will now pop up on any of the areas that an input is required. Forthe purposes ofthis assignment length, I will refrain from putting any further “Invalid Entries” The normal “Name” input. This has now been added to guide the user to the specific area for ordering their item or product. One more “Invalid Entry to show that the invalid entry does work on the new areas.
  • 32. PROGRAMMING 32 We are now going to the “Case” section. The program validates the user’s request for the selected area. Now we have the brand to be ordered. A Cooler Master case seems to be our brand. Here it is validated and confirmed for order. Next is the model, which is an ATX High Tower. Want to fit a lot in there.
  • 33. PROGRAMMING 33 Again we have confirmation. The color choice is black for the case. Confirmation is again completed. The size only comes in three sizes MATX, ATX, or BTX so we are not adding a number here. Just “N/A”. It is confirmed in this splash. If nothing were entered it WOULD return and error. Quantity of cases is added here. This is where an integer is considered.
  • 34. PROGRAMMING 34 Validity is confirmed here. Again, from before, we have input the phone number request. It is confirmed when entered correctly. Here the customer receives the accomplishment page for their order. It exhibits all information from before and also addresses the extra classes added in for this feature.
  • 35. PROGRAMMING 35 It also addresses the information in the running virtual environment to ensure everything is going to the (file.write). Here we see the files have been built into the database. When notepad is opened, all the information presents itself to the business to be filled. Conclusion The overall function of personal classes can greatly enhance the functionality of any program being built. It’s a nice loop hole built in to create easy flowing programs that might not already be built within the system. In a way it is like adding a few slang words to the language vocabulary to enhance your overall communication of thought.
  • 36. PROGRAMMING 36 Chapter 5 - Inheritance and Polymorphism Arrays and Sub Classes Last week we integrated a superclass to apply objects to our programming fields. It introduced the “get method” to pull information from certain objects, when needed. This week’s work has expounded on those methods as to where subclasses have been integrated into the program and through the use of inheritance and polymorphism, these files can be called on to perform functions within the main program. These are used to generate instances within the program when using arrays to perform the actions. When applying all these new subclasses, I found there were a lot of modifications needed to the main program in order for everything to operate in a functional means. The “main static void” had to be tremendously altered to accommodate the new functions using inheritance and polymorphism techniques. Below is a snap shot of the added information using inheritance techniques and polymorphism techniques. openingMsg = "Welcome to Claw Concepts"+"n" + "Shop for the computer of your dreams!"; JOptionPane.showMessageDialog(null, openingMsg); prompt = "What's Your Name Please?"; customerName = getStringInput(prompt); phn=VLDNO(); while (makeOrder.equalsIgnoreCase("yes")) { prompt = "What section would you like today? " + "n" + "Please ENTER Number Option : " + "n" + " ( 1 ) for Desktop Systems " + "n" + " ( 2 ) for Laptop Systems " + "n" + " ( 3 ) for Tablets " + "n";
  • 37. PROGRAMMING 37 section = getStringInput(prompt); secType= Integer.parseInt(section); if (secType== 1){ JOptionPane.showMessageDialog(null,"Section selected is: Desktops ");} else if (secType== 2){ JOptionPane.showMessageDialog(null,"Brand selected is: Laptops ");} else if (secType== 3){ JOptionPane.showMessageDialog(null,"Brand Selected is: Tablets "); } prompt = "What brand will you be ordering today? : " + "n" + " Please Enter : " + "n" + " ( 1 ) for Hewlett Packard " + "nn" + " ( 2 ) for Dell - Alienware " + "nn" + " ( 3 ) for Gateway - Acer " + "nn"; brand = getStringInput(prompt); bType = Integer.parseInt(brand); if (bType == 1){ JOptionPane.showMessageDialog(null,"Brand selected is: HewlettPackard ");} else if (bType == 2){ JOptionPane.showMessageDialog(null,"Brand selected is: Dell ");} else if (bType == 3){ JOptionPane.showMessageDialog(null,"Brand Selected is: Acer Ware "); } prompt = "Which model would you like ? " +"n" + " Please Enter : " + "n" + " ( 1 ) for HP Envy 810-160 " + "nn" + " ( 2 ) for HP Pavilion 17-e117dx " + "nn" + " ( 3 ) for HP 10 Plus 10.1-Inch 16 GB " + "nn" + " ( 4 ) for Dell OptiPlex Core i7 i7-3770 3.40 GHz mATX " + "nn" + " ( 5 ) for Dell Inspiron 17R TouchscreenGaming Laptop " + "nn" + " ( 6 ) for Dell Venue 8 Pro 32 GB Tablet " + "nn"
  • 38. PROGRAMMING 38 + " ( 7 ) for Acer Predator AG3-605-UR2E Core i7-4770 " + "nn" + " ( 8 ) for Acer Aspire E5-771-378Y " + "nn" + " ( 9 ) for Acer Aspire Switch 10 SW5-011-18R3 " + "nn"; model = getStringInput(prompt); mType = Integer.parseInt(model); if (mType == 1){JOptionPane.showMessageDialog(null, "Your selected HP Model Desktop is: HP Envy 810-160 "); costPerItem = 329.00;} else if (mType == 2){ JOptionPane.showMessageDialog(null, "Your selected HP Model Laptop is: HP Pavilion 17-e117dx "); costPerItem = 469.00;} else if (mType == 3){JOptionPane.showMessageDialog(null, "Your selected HP Model Tablet is: HP 10 Plus 10.1-Inch 16 GB "); costPerItem = 229.00;} else if (mType == 4){ JOptionPane.showMessageDialog(null, "Your selected DellModel Desktop is: Dell OptiPlex Core i7 i7- 3770 3.40 GHz mATX "); costPerItem = 529.00;} else if (mType == 5){JOptionPane.showMessageDialog(null, "Your selected Dell Model Laptop is: Dell Inspiron 17R TouchscreenGaming Laptop "); costPerItem = 479.00;} else if (mType == 6){ JOptionPane.showMessageDialog(null, "Your selected Dell Model Tablet is: Dell Venue 8 Pro 32 GB Tablet "); costPerItem = 139.00;} else if (mType == 7){JOptionPane.showMessageDialog(null, "Your selected Acer Model Desktop is: Acer Predator AG3-605- UR2E Core i7-4770 "); costPerItem = 429.00;} else if (mType == 8){ JOptionPane.showMessageDialog(null, "Your selected Acer Model Laptop is: Acer Aspire E5-771-378Y "); costPerItem = 289.00;} else if (mType == 9){JOptionPane.showMessageDialog(null, "Your selected Acer Model Tablet is: Acer Aspire Switch 10 SW5-011-18R3 "); costPerItem = 168.00;}
  • 39. PROGRAMMING 39 prompt = "What color option would you like?" + "n" + " Please Enter : " + "n" + " ( 1 ) for Black " + "n" + " ( 2 ) for Silver " + "n" + " ( 3 ) for Gun Silver " + "n" + " ( 4 ) for Blue " + "n" + " ( 5 ) for Green " + "n" + " ( 6 ) for Red " + "n"; color = getStringInput(prompt); cType = Integer.parseInt(color); if (cType == 1){JOptionPane.showMessageDialog(null, "Your selected Color is: Black ");} else if (cType == 2){ JOptionPane.showMessageDialog(null, "Your selected Color is: Silver ");} else if (cType == 3){ JOptionPane.showMessageDialog(null, "Your selected Color is: Gun Silver ");} else if (cType == 4){ JOptionPane.showMessageDialog(null, "Your selected Color is: Blue ");} else if (cType == 5){ JOptionPane.showMessageDialog(null, "Your selected Color is: Green ");} else if (cType == 6){ JOptionPane.showMessageDialog(null, "Your selected Color is: Red ");} prompt = "Please enter Size? " + "n" + " ( 1 ) for ATX " + "nn" + " ( 2 ) for BTX " + "nn" + " ( 3 ) for 17.3 inch Laptop " + "nn" + " ( 4 ) for 15.3 inch Laptop " + "nn" + " ( 5 ) for 10.1 inch Tablet " + "nn" + " ( 6 ) for 9.7 inch Tablet " + "nn" + "If size not needed. ENTER: N/A "; size = getStringInput(prompt); sType = Integer.parseInt(size); if (sType == 1){JOptionPane.showMessageDialog(null, "Your selected Desktop Size is: ATX ");} else if (sType== 2){ JOptionPane.showMessageDialog(null, "Your selected Desktop Size is: BTX ");} else if (sType== 3){ JOptionPane.showMessageDialog(null,
  • 40. PROGRAMMING 40 "Your selected Laptop Size is: 17.3 inches ");} else if (sType== 4){ JOptionPane.showMessageDialog(null, "Your selected Laptop Size is: 15.3 inches ");} else if (sType== 5){ JOptionPane.showMessageDialog(null, "Your selected Tablet Size is: 10.1 inches ");} else if (sType== 6){ JOptionPane.showMessageDialog(null, "Your selected Tablet Size is: 9.7 inches ");} else if (sType== 7){ JOptionPane.showMessageDialog(null, " Size Not needed Enter: N/A ");} Using this method, we are capable of pulling up different options verses utilizing only single question and answer methods and it makes the process more user friendly by adding the ability to just enter numerical values; versus having to type in all the information. However, by completing this style, arrays do have to be added to the process so that the program can incorporate the number sequence for the user. Thus, the script presented, to work with the aforementioned script above will look something like this and should return multiple values with the virtual environment when initiated. The following is the required additional script as well as a presentation of all possible values generated when the string has been started. String[]Section; Section = new String[3]; String[]Brand; Brand = new String[3]; String[]Model; Model = new String[9]; String[]Color; Color = new String[6]; String[]Size; Size = new String[7]; Section[0]= "Desktops"; Section[1]= "Laptops"; Section[2]= "Tablets";
  • 41. PROGRAMMING 41 Brand[0]= "Hewlett Packard"; Brand[1]= "Dell"; Brand[2]= "Acer Ware"; Model[0]="HP Envy 810-160"; Model[1]="HP Pavilion 17-e117dx"; Model[2]="HP 10 Plus 10.1-Inch 16 GB"; Model[3]="Dell OptiPlex Core i7 i7-3770 3.40 GHz"; Model[4]="Dell Inspiron 17R TouchscreenGaming Laptop"; Model[5]="Dell Venue 8 Pro 32 GB Tablet"; Model[6]="Acer Predator AG3-605-UR2E Core i7-4770"; Model[7]="Acer Aspire E5-771-378Y"; Model[8]="Acer Aspire Switch 10 SW5-011-18R3"; Color[0]="Black"; Color[1]="Silver"; Color[2]="Gun Silver"; Color[3]="Blue"; Color[4]="Green"; Color[5]="Red"; Size[0]="ATX"; Size[1]="BTX"; Size[2]="17.3 inch"; Size[3]="15.3 inch"; Size[4]="10.1 inch"; Size[5]="9.7 inch"; for (int i = 0;i <= 2;i++){ for (int j = 0;j <= 2;j++){ for (int k = 0;k <= 8;k++){ for (int m = 0;m <= 5;m++){ for (int n = 0;n <= 5;n++){ System.out.println("Section: "+Section[i]+" "+ "Brand: " +Brand[j]+" "+"Model: "+Model[k]+" "+ "color: "+Color[m]+" "+"size: "+Size[n]); } }
  • 42. PROGRAMMING 42 } } } Section sectionTypes = new Section(); Brand brandTypes = new Brand(); Model modelTypes = new Model(); Color colorTypes = new Color(); Size sizeTypes = new Size(); After I complete the writing portion of the script noted above, I was amazed by the immensity of the number of lines required to get a string to run with all variables. Once completed the output on the virtual environment within the program pumped out a whopping amount of information and possibilities as is shown below. This generated over 300 pages of information in the output window, but for the purposes of this document, I will only be inserting three pages to represent some of the possibilities the program presented to evaluate customer selection. Three hundred pages was a little too much for the doc. Virtual Output run: Section: Desktops Brand: Hewlett Packard Model: HP Envy 810-160 color: Black size: ATX Section: Desktops Brand: Hewlett Packard Model: HP Envy 810-160 color: Black size: BTX Section: Desktops Brand: Hewlett Packard Model: HP Envy 810-160 color: Black size: 17.3 inch
  • 43. PROGRAMMING 43 Section: Desktops Brand: Hewlett Packard Model: HP Envy 810-160 color: Black size: 15.3 inch Section: Desktops Brand: Hewlett Packard Model: HP Envy 810-160 color: Black size: 10.1 inch Section: Desktops Brand: Hewlett Packard Model: HP Envy 810-160 color: Black size: 9.7 inch Section: Desktops Brand: Hewlett Packard Model: HP Envy 810-160 color: Silver size: ATX Section: Desktops Brand: Hewlett Packard Model: HP Envy 810-160 color: Silver size: BTX Section: Desktops Brand: Hewlett Packard Model: HP Envy 810-160 color: Silver size: 17.3 inch Section: Desktops Brand: Hewlett Packard Model: HP Envy 810-160 color: Silver size: 15.3 inch Section: Desktops Brand: Hewlett Packard Model: HP Envy 810-160 color: Silver size: 10.1 inch Section: Desktops Brand: Hewlett Packard Model: HP Envy 810-160 color: Silver size: 9.7 inch Section: Desktops Brand: Hewlett Packard Model: HP Envy 810-160 color: Gun Silver size: ATX
  • 44. PROGRAMMING 44 Section: Desktops Brand: Hewlett Packard Model: HP Envy 810-160 color: Gun Silver size: BTX Section: Desktops Brand: Hewlett Packard Model: HP Envy 810-160 color: Gun Silver size: 17.3 inch Section: Desktops Brand: Hewlett Packard Model: HP Envy 810-160 color: Gun Silver size: 15.3 inch Section: Desktops Brand: Hewlett Packard Model: HP Envy 810-160 color: Gun Silver size: 10.1 inch Section: Desktops Brand: Hewlett Packard Model: HP Envy 810-160 color: Gun Silver size: 9.7 inch Section: Desktops Brand: Hewlett Packard Model: HP Envy 810-160 color: Blue size: ATX Section: Desktops Brand: Hewlett Packard Model: HP Envy 810-160 color: Blue size: BTX Section: Desktops Brand: Hewlett Packard Model: HP Envy 810-160 color: Blue size: 17.3 inch Section: Desktops Brand: Hewlett Packard Model: HP Envy 810-160 color: Blue size: 15.3 inch Section: Desktops Brand: Hewlett Packard Model: HP Envy 810-160 color: Blue size: 10.1 inch
  • 45. PROGRAMMING 45 Section: Desktops Brand: Hewlett Packard Model: HP Envy 810-160 color: Blue size: 9.7 inch Section: Desktops Brand: Hewlett Packard Model: HP Envy 810-160 color: Green size: ATX Section: Desktops Brand: Hewlett Packard Model: HP Envy 810-160 color: Green size: BTX Section: Desktops Brand: Hewlett Packard Model: HP Envy 810-160 color: Green size: 17.3 inch Section: Desktops Brand: Hewlett Packard Model: HP Envy 810-160 color: Green size: 15.3 inch BUILD SUCCESSFUL (total time: 9 seconds) ScreenShots of Operation with Arrays As the program began to run, the following screen shots appeared. The formal welcome screen is presented to the user. The customer’s name is asked.
  • 46. PROGRAMMING 46 The use of an appropriate number is asked to be entered. The exception generator is still in place in case they make a mistake. Once phone number is validated a valid responseis issued. The customer is now asked to enter a number option for which section they want to go to. Here, I have entered (2) for laptops The program now confirms the laptop section has been selected. The program now has for the brand that the customer desires to look at. Again, I have picked number 2 for Dell-Alien ware.
  • 47. PROGRAMMING 47 The program now confirms the laptop brand has been selected. The system now asks which model I would like out of the Dells listed. I picked the Dell 17R touchscreen laptop. It is confirmed as the Dell 17R. Blue was my choice for a nice cover for the laptop.
  • 48. PROGRAMMING 48 The program verifies that it is blue that has been selected. In this frame, the customer chooses the size of their system. The first two are for desktops, the next two are for laptops and the last two are for tablets. I am choosing (3) for the 17 inch screen. Here, we see that option 3 is chosen and verified for the 17 inch screen. In this frame the customer is asked for the quantity. I picked three laptops as I am greedy and like laptops. Quantity is verified for three laptops. Hope I have enough on my credit card.
  • 49. PROGRAMMING 49 The system asks me if I want to order anything else. I think I spent enough. Here, the final message shows the numbers picked for my choices. It also shows costper item, tax, and total cost of purchase. Now I get to go out and work so I can pay it all off. Finally, we have the document that was sent to file in the cc-final program. The itemized order needed to fulfill the order by the customer.
  • 50. PROGRAMMING 50 Conclusion In this phase, it was shown how to put polymorphism and inheritance into the program to supercharge the overall capability of the program. By building a superclass, adding methods to the superclass and inheriting additional files to pull from; we were able to make the program more user friendly when entering the required information to fulfill the order. The customer was now able to enter just numbers instead of having to type or enter the required information into the system. Polymorphism and inheritance give the program a stream lining affect for the computer, customer and programmer. It’s a win-win situation for all parties involved. References There are no sources in the current document. All entries developed by the author.