0% found this document useful (0 votes)
3 views3 pages

Program Code

This document outlines a smart packing list generator for trips, created collaboratively by two partners. It includes a master inventory of items and a function that generates a packing list based on user inputs regarding weather, regions, trip duration, and type. The program features navigation buttons for user interaction and displays the final packing list on a results screen.

Uploaded by

dhruvhydrox
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views3 pages

Program Code

This document outlines a smart packing list generator for trips, created collaboratively by two partners. It includes a master inventory of items and a function that generates a packing list based on user inputs regarding weather, regions, trip duration, and type. The program features navigation buttons for user interaction and displays the final packing list on a results screen.

Uploaded by

dhruvhydrox
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

// App Purpose: A smart packing list generator for trips.

// Program written collaboratively by Partner A and Partner B

// Partner A: my main list of all the clothes and gear for the app.
// keeps everything organized in one place instead of a million variables.
var masterInventory = [
"T-shirts", "Jeans", "Phone Charger", "Toothbrush",
"Light Jacket", "Heavy Coat", "Shorts", "Thermal Wear",
"Swimsuit", "Beach Towel", "Sunscreen", "Bug Spray", "Hiking Boots",
"Comfortable Walking Shoes", "Motion Sickness Pills",
"Small Daypack", "Travel-Size Toiletries", "Extra Laundry Bag",
"Laundry Detergent Pods", "Business Suit", "Laptop", "First Aid Kit",
"Large Backpack"
];

setScreen("screen0");

// Partner B: when the user clicks generate, grab all their answers
onEvent("Generate", "click", function() {

// getting the user's input from the dropdown menus


var w = getText("weather");
var r = getText("Regions");
var d = getText("TripDuration");
var t = getText("TripType");

// call the function to figure out what bags to pack


var finalBags = buildList(w, r, d, t, masterInventory);

// switch to the results screen and print out the final packing list
setScreen("screen2");
setText("outputArea", [Link]("\n"));
});

// Partner A: function to figure out exactly what items to pack based on the trip details
// takes in the user's answers and the master list and returns the packed items
function buildList(wTarget, rTarget, dTarget, tTarget, allItems) {
var packedItems = [];

// Partner B: loop through every single item in our master inventory list
for (var i = 0; i < [Link]; i++) {
var item = allItems[i];

// big block of if/else statements to check the weather, location, etc.


// to see if we actually need to pack this specific item
if (item == "T-shirts" || item == "Jeans" || item == "Phone Charger" || item == "Toothbrush") {
appendItem(packedItems, item);
}
else if (item == "Swimsuit" && (wTarget == "Hot" || wTarget == "Mild") && (rTarget == "Beach"
|| rTarget == "Tropical" || rTarget == "Cruise")) {
appendItem(packedItems, item);
}
else if (item == "Beach Towel" && (rTarget == "Beach" || rTarget == "Tropical")) {
appendItem(packedItems, item);
}
else if (item == "Shorts" && (wTarget == "Hot" || wTarget == "Mild")) {
appendItem(packedItems, item);
}
else if (item == "Light Jacket" && (wTarget == "Mild" || wTarget == "Cold")) {
appendItem(packedItems, item);
}
else if (item == "Heavy Coat" && wTarget == "Cold") {
appendItem(packedItems, item);
}
else if (item == "Thermal Wear" && wTarget == "Cold" && (rTarget == "Mountain" || rTarget ==
"Park")) {
appendItem(packedItems, item);
}
else if (item == "Bug Spray" && (wTarget == "Hot" || wTarget == "Mild") && (rTarget ==
"Tropical" || rTarget == "Park" || rTarget == "Rural" || rTarget == "Mountain")) {
appendItem(packedItems, item);
}
else if (item == "Sunscreen" && (wTarget == "Hot" || rTarget == "Beach" || rTarget ==
"Tropical")) {
appendItem(packedItems, item);
}
else if (item == "Comfortable Walking Shoes" && (rTarget == "City" || rTarget == "Culinary" ||
rTarget == "Park")) {
appendItem(packedItems, item);
}
else if (item == "Hiking Boots" && (rTarget == "Mountain" || rTarget == "Park" || rTarget ==
"Rural")) {
appendItem(packedItems, item);
}
else if (item == "Motion Sickness Pills" && rTarget == "Cruise") {
appendItem(packedItems, item);
}
else if (item == "Small Daypack" && dTarget == "Hours") {
appendItem(packedItems, item);
}
else if (item == "Travel-Size Toiletries" && (dTarget == "Couple Days" || dTarget == "Weeks"))
{
appendItem(packedItems, item);
}
else if (item == "Extra Laundry Bag" && (dTarget == "Weeks" || dTarget == "2+ Weeks" ||
dTarget == "Month(s)")) {
appendItem(packedItems, item);
}
else if (item == "Laundry Detergent Pods" && dTarget == "Month(s)") {
appendItem(packedItems, item);
}
else if ((item == "Business Suit" || item == "Laptop") && tTarget == "Business") {
appendItem(packedItems, item);
}
else if (item == "First Aid Kit" && (tTarget == "Family" || tTarget == "Backpacking")) {
appendItem(packedItems, item);
}
else if (item == "Large Backpack" && tTarget == "Backpacking") {
appendItem(packedItems, item);
}
}

// Partner A: send the finished list back


return packedItems;
}

// Partner B: navigation buttons


onEvent("homeButton", "click", function() {
[Link]("homeButton clicked!");
setScreen("screen0");
});

onEvent("screen0", "click", function() {


[Link]("screen0 clicked!");
});

onEvent("button4", "click", function() {


[Link]("button4 clicked!");
setScreen("screen1");
});

You might also like