0% found this document useful (0 votes)
13 views1 page

Code Print

The document describes a browser tool called AP PT CodePrint designed for preparing code submissions for the AP CSP Performance Tasks. It includes features for formatting code, setting font sizes, and printing to PDF, along with a sample project titled 'U.S. National Park Generator' that demonstrates how to generate random national park information based on user input. The document also outlines the functionality of various buttons and events within the project code.
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)
13 views1 page

Code Print

The document describes a browser tool called AP PT CodePrint designed for preparing code submissions for the AP CSP Performance Tasks. It includes features for formatting code, setting font sizes, and printing to PDF, along with a sample project titled 'U.S. National Park Generator' that demonstrates how to generate random national park information based on user input. The document also outlines the functionality of various buttons and events within the project code.
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
You are on page 1/ 1

AP PT CodePrint © Baker Franke 2017

A one-stop shopping browser tool for preparing your code to submit for the AP CSP Performance Tasks.
If you can print a PDF from the browser, this should be everything you need.
▸ Update: nov 13, 2018 (click to expand)

(1) Type (or paste) your code into the big box below. Add titles if you like. Click this button Prettify if you don't see the code being laid out prettily below.
Project Title: U.S. National Park GeneratorOther Text:
var index;
if (category === "small" && filteredSmallNames.length > 0) {
index = randomNumber(0, filteredSmallNames.length - 1);
return {
name: filteredSmallNames[index],
location: filteredSmallLocations[index],
description: filteredSmallDescriptions[index],
image: filteredSmallImages[index]
};
} else if (category === "large" && filteredLargeNames.length > 0) {
index = randomNumber(0, filteredLargeNames.length - 1);
return {
name: filteredLargeNames[index],
location: filteredLargeLocations[index],
description: filteredLargeDescriptions[index],
image: filteredLargeImages[index]
};
(2) Set font size and draw shapes on the code. (3) Hide the controls. (4) Print to PDF from the browser.
Font Size: 12px | Draw Shape: Rect Clear Rect Clear All
Hide/Show Controls Print

U.S. National Park Generator

1 var names = getColumn("US National Parks", "Name");


2 var images = getColumn("US National Parks", "Image");
3 var locations = getColumn("US National Parks", "Location");
4 var description = getColumn("US National Parks", "Description");
5 var acresArea = getColumn("US National Parks", "Area in acres");
6
7 // Purpose: Move the user to the "bigger_or_smaller_park_screen"
8 //when the start button is clicked.
9 onEvent("start_button", "click", function() {
10 setScreen("bigger_or_smaller_park_screen");
11 playSound("sound://category_app/app_button_3.mp3", false);
12 });
13
14 // Purpose: Reset the app and clear displayed data when the user clicks the restart
15 //button.
16 onEvent("restart_button", "click", function() {
17 setScreen("national_park_home_screen");
18 setProperty("description_text_area", "text", "");
19 setProperty("location_text_area", "text", "");
20 setProperty("name_text_area", "text", "");
21 setProperty("random_image", "image", "");
22 playSound("sound://category_app/app_button_click_1.mp3", false);
23 });
24
25 var filteredSmallNames = [];
26 var filteredSmallLocations = [];
27 var filteredSmallImages = [];
28 var filteredSmallDescriptions = [];
29 var filteredLargeNames = [];
30 var filteredLargeLocations = [];
31 var filteredLargeImages = [];
32 var filteredLargeDescriptions = [];
33 var area = "";
34
35 // Filter parks into smaller and larger categories
36 updateScreen();
37
38 // Purpose: Take the user to the results screen and store their selection of park size.
39 onEvent("next_button", "click", function() {
40 setScreen("results_screen");
41 area = getText("size_dropdown");
42 playSound("sound://category_app/app_button_2.mp3", false);
43 });
44
45 // Purpose: Display a random park based on the user’s selected size (small or large).
46 onEvent("get_park_button", "click", function() {
47 var park;
48 if (area == "Smaller parks") {
49 park = getRandomPark("small");
50 } else if (area == "Larger parks") {
51 park = getRandomPark("large");
52 }
53
54 if (park) {
55 setText("name_text_area", park.name);
56 setText("location_text_area", park.location);
57 setText("description_text_area", park.description);
58 setProperty("random_image", "image", park.image);
59 }
60
61 playSound("sound://category_app/app_button_5.mp3", false);
62 });
63
64 // Purpose: Categorize parks into "small" (area < 20,000 acres) and "large"
65 //(area ≥ 20,000 acres).
66 function updateScreen() {
67 for (var i = 0; i < names.length; i++) {
68 if (acresArea[i] < 20000) {
69 appendItem(filteredSmallNames, names[i]);
70 appendItem(filteredSmallLocations, locations[i]);
71 appendItem(filteredSmallImages, images[i]);
72 appendItem(filteredSmallDescriptions, description[i]);
73 } else {
74 appendItem(filteredLargeNames, names[i]);
75 appendItem(filteredLargeLocations, locations[i]);
76 appendItem(filteredLargeImages, images[i]);
77 appendItem(filteredLargeDescriptions, description[i]);
78 }
79 }
80 }
81
82 // Purpose: Get a random park based on the category ("small" or "large").
83 // Functionality: Returns an object containing the name, location, description, and
84 //image of a randomly selected park.
85 function getRandomPark(category) {
86 var index;
87 if (category === "small" && filteredSmallNames.length > 0) {
88 index = randomNumber(0, filteredSmallNames.length - 1);
89 return {
90 name: filteredSmallNames[index],
91 location: filteredSmallLocations[index],
92 description: filteredSmallDescriptions[index],
93 image: filteredSmallImages[index]
94 };
95 } else if (category === "large" && filteredLargeNames.length > 0) {
96 index = randomNumber(0, filteredLargeNames.length - 1);
97 return {
98 name: filteredLargeNames[index],
99 location: filteredLargeLocations[index],
100 description: filteredLargeDescriptions[index],
101 image: filteredLargeImages[index]
102 };
103 }
104 return null;
105 }
106
107 //Mountain image in the home screen is from https://www.google.com/url?sa=i&url=https%3
108 //A%2F%2Fwww.vecteezy.com%2Ffree-png%2Fmountains-png&psig=AOvVaw3TXx2AwGLzbMZcywa-GJd1&
109 //ust=1734484372193000&source=images&cd=vfe&opi=89978449&ved=0CBQQjhxqFwoTCOi19vjPrYoDF
110 //QAAAAAdAAAAABAE
111 //All the tree images in the home screen is from https://png.pngtree.com/png-clipart/202
112 //20730/ourmid/pngtree-isolated-redwood-tree-on-transparent-background-png-image_609291
113 //3.png
114 //Lake image in the home screen is from https://static.vecteezy.com/system/resources/
115 //thumbnails/041/713/973/small_2x/ai-generated-serene-lake-with-lush-green-mountainous-
116 //backdrop-in-a-tranquil-environment-on-transparent-background-stock-png.png
117 //Birds image in the home screen is from https://static.vecteezy.com/system/resources/t
118 //humbnails/021/594/744/small/flying-birds-silhouettes-pattern-wallpaper-transparent-is
119 //olated-bird-flying-tattoo-design-template-for-card-package-and-wallpaper-png.png
120 //Sunset in the question screen is from https://www.pngmart.com/files/22/Sunset-PNG.png
121 //The canynon photo in the question screen is from https://static.vecteezy.com/system
122 ///resources/thumbnails/049/515/092/small/majestic-sandstone-canyons-at-sunset-in-a-
123 //remote-desert-landscape-cut-out-transparent-png.png
124 //the birds image in the question screen is from https://png.pngtree.com/png-vector/202
125 //40206/ourmid/pngtree-birds-fly-in-the-clouds-png-image_11668057.png
126 //The tree images in the results screen is from https://static.vecteezy.com/system
127 ///resources/thumbnails/037/500/612/small/ai-generated-trees-natural-free-png.png
128 //The plot of land in the results screen is from https://static.vecteezy.com/system
129 ///resources/thumbnails/041/714/021/small/ai-generated-lush-green-forest-covering-seren
130 //e-mountainous-landscape-on-transparent-background-stock-png.png
131
132

PDF document made with CodePrint using Prism

You might also like