DOC PREVIEW
Penn CIT 591 - Program Examples

This preview shows page 1-2-3-4-5-6 out of 19 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 19 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 19 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 19 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 19 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 19 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 19 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 19 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Program ExamplesPre commentsPassword checkerAssorted testsMore testsAccess testInteresting loopSetting up a Choice (drop-down list)Case testingMore casesRandomPolymorphism? What’s that?Pop-upsMore pop-upsYet more pop-upsAn HTML formThe dialogFileMatrixThe EndJan 14, 2019Program ExamplesThe Good, the Bad, and the UglyPre commentsMany of these examples are not Java, so if the syntax is a bit strange, don’t worry about thatSome of these examples work, some don’tExcept as noted, the examples are from http://www.thedailywtf.com(I may have made a few minor editing changes)Password checkerprivate void txtHostname_KeyPress(object sender, KeyPressEventArgs e) { StringBuilder sb = new StringBuilder(); sb.Append("SELECT Passwd FROM [Users] WHERE Username='"); sb.Append(this.txtUsername.Text + "'"); String password = GetPassword(sb.ToString()); for (int i = 0; i < (sender as TextBox).Text.Length; i++) { if (password[i] == (sender as TextBox).Text[i]) { this.lblError.Text = ""; } else this.lblError.Text = "Incorrect Password!"; if (i == (sender as TextBox).Text.Length) { if (password[i] == (sender as TextBox).Text[i]) { LogUserIn(this.txtUsername.Text); } } }}Assorted testsif (Math.max(1, 2) == 2) return; If Not IsPostBack Then If Not IsPostBack Then LoadReport() End IfEnd If IF 0 > 0BEGIN SELECT 'Equipment is in use‘ RETURNENDMore testsIf Not(blnIsDirty = True) Then ' Do NothingElse UpdateAccountRecordEnd If//return whether a double is negativebool IsNegative(double n){ string nStr = n.ToString(); if (nstr.IndexOf('-', 0, 1)) return true; return false;}Access testIf ((mintAccessLevelForm = NO_ACCESS) Or _ ((mintOperationMode = OP_NEW) And (mintAccessLevelForm = READ_ACCESS) And _ (mintOperationMode = OP_NEW) And (mintAccessLevelIndividuals = READ_ACCESS) And _ (mintOperationMode = OP_NEW) And (mintAccessLevelAddressAlias = READ_ACCESS) And _ (mintOperationMode = OP_NEW) And (mintAccessLevelContracts = READ_ACCESS) And _ (mintOperationMode = OP_NEW) And (mintAccessLevelCostCenter = READ_ACCESS) And _ (mintOperationMode = OP_NEW) And (mintAccessLevelCorrespondence = READ_ACCESS) And _ (mintOperationMode = OP_NEW) And (mintAccessLevelAccountProfile = READ_ACCESS) And _ (mintOperationMode = OP_NEW) And (mintAccessLevelInstructions = READ_ACCESS) And _ (mintOperationMode = OP_NEW) And (mintAccessLevelFBOVendors = READ_ACCESS) And _ (mintOperationMode = OP_NEW) And (mintAccessLevelFBOChains = READ_ACCESS) And _ (mintOperationMode = OP_NEW) And (mintAccessLevelCatering = READ_ACCESS) And _ (mintOperationMode = OP_NEW) And (mintAccessLevelGround = READ_ACCESS) And _ (mintOperationMode = OP_NEW) And (mintAccessLevelAccountProfileOSR = READ_ACCESS)) Or _ ((mintOperationMode = OP_NEW) And (mintAccessLevelForm <> FULL_ACCESS) Or _ (mintOperationMode = OP_NEW) And (mintAccessLevelIndividuals <> FULL_ACCESS) Or _ (mintOperationMode = OP_NEW) And (mintAccessLevelAddressAlias <> FULL_ACCESS) Or _ (mintOperationMode = OP_NEW) And (mintAccessLevelContracts <> FULL_ACCESS) Or _ (mintOperationMode = OP_NEW) And (mintAccessLevelCostCenter <> FULL_ACCESS)Or _ (mintOperationMode = OP_NEW) And (mintAccessLevelCorrespondence <> FULL_ACCESS) Or _ (mintOperationMode = OP_NEW) And (mintAccessLevelAccountProfile <> FULL_ACCESS) Or _ (mintOperationMode = OP_NEW) And (mintAccessLevelInstructions <> FULL_ACCESS) Or _ (mintOperationMode = OP_NEW) And (mintAccessLevelFBOVendors <> FULL_ACCESS) Or _ (mintOperationMode = OP_NEW) And (mintAccessLevelFBOChains <> FULL_ACCESS) Or _ (mintOperationMode = OP_NEW) And (mintAccessLevelCatering <> FULL_ACCESS) Or _ (mintOperationMode = OP_NEW) And (mintAccessLevelGround <> FULL_ACCESS) Or _ (mintOperationMode = OP_NEW) And (mintAccessLevelAccountProfileOSR <> FULL_ACCESS))) Then DisplayNoAccessMessage Exit FunctionEnd IfInteresting loopfor (int i = 0; i < 12; i++) { switch(i) { case 0: list = paymentMethod; logger.debug("Payment method set."); break; case 1: list = productCategory; logger.debug("Product category set."); break; ... // I've omitted similar cases 2 through 10 case 11: list = productWaight; logger.debug("Product weight set."); default: list = new ArrayList(); logger.debug("Unknown value"); break; }}Setting up a Choice (drop-down list)annualMileageChoice = new Choice()annualMileageChoice.addItem(CHO_PLEASE_ENTER);annualMileageChoice.addItem("500")annualMileageChoice.addItem("1000")annualMileageChoice.addItem("1500")annualMileageChoice.addItem("2000")annualMileageChoice.addItem("2500")annualMileageChoice.addItem("3000")annualMileageChoice.addItem("3500");…annualMileageChoice.addItem("44000");annualMileageChoice.addItem("44500");annualMileageChoice.addItem("45000");Case testingMore casesRandomint invoiceId = new Random().nextInt(); hi all,IntTemp = Int((255 * Rnd()) + 1)I used above ASP.NET code. Problem is in " Rnd() "Rnd() value is changing everytime.What is the alternative for Rnd()? OR How will stop Rnd() value changes at everytime?if ($hour>=7 and $hour<18) { # Assign randomly to Biff or Cliff if (rand() > 0.5) {$Owner->LoadById('70656');} if (rand() < 0.5) {$Owner->LoadById('72586');}}Polymorphism? What’s that?if(obj instanceof MMSNode) { MMSNode node = (MMSNode)obj; attribs = node.getAttribs();}else if(obj instanceof MMSPhysComp) { MMSPhysComp physComp = (MMSPhysComp)obj; attribs = physComp.getAttribs();}else if(obj instanceof MMSLogComp) { MMSLogComp logComp = (MMSLogComp)obj; attribs = logComp.getAttribs();}else if (obj instanceof MMSPhysLink) { MMSPhysLink physLink = (MMSPhysLink)obj; attribs = physLink.getAttribs();}Pop-upsMore pop-upsYet more pop-upsAn HTML formThe dialogFileMatrixThe


View Full Document

Penn CIT 591 - Program Examples

Documents in this Course
Stacks

Stacks

11 pages

Arrays

Arrays

30 pages

Arrays

Arrays

29 pages

Applets

Applets

24 pages

Style

Style

33 pages

JUnit

JUnit

23 pages

Java

Java

32 pages

Access

Access

18 pages

Methods

Methods

29 pages

Arrays

Arrays

32 pages

Methods

Methods

9 pages

Methods

Methods

29 pages

Vectors

Vectors

14 pages

Eclipse

Eclipse

23 pages

Vectors

Vectors

14 pages

Recursion

Recursion

24 pages

Animation

Animation

18 pages

Animation

Animation

18 pages

Static

Static

12 pages

Eclipse

Eclipse

23 pages

JAVA

JAVA

24 pages

Arrays

Arrays

29 pages

Animation

Animation

18 pages

Numbers

Numbers

21 pages

JUnit

JUnit

23 pages

Access

Access

18 pages

Applets

Applets

24 pages

Methods

Methods

30 pages

Buttons

Buttons

20 pages

Java

Java

31 pages

Style

Style

28 pages

Style

Style

28 pages

Load more
Download Program Examples
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Program Examples and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Program Examples 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?