Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sets and Maps Diosaban #23

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions SetandMaps/SetandMaps.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Dart SDK" level="project" />
</component>
</module>
37 changes: 37 additions & 0 deletions SetandMaps/bin/main.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import 'dart:io';
import 'dart:math';

void main(List<String> arguments) {

//Dart Set Exercise
const a = <int>{1,2,5,7,8};
const b = <int>{1,3,5,7,9};

var belongA = (a.difference(b));
var belongB = (b.difference(a));
var aB = belongA.union(belongB);

print("Dart Set Exercise");
print(aB);
var sum = aB.reduce((a, b) => a + b);
print("The sum of the set of the elements that belong to either `a` or `b`, but not both is " + sum.toString());

//Dart Maps Exercise
print("Dart Map Exercise");

var pizzaPrices = <String, double>{
'margherita': 5.5,
'pepperoni': 7.5,
'vegetarian': 6.5,
};

var orderTotal = pizzaPrices['margherita'] + pizzaPrices['pepperoni'];
print('\nYour order is Margherita Pizza and Pepperoni Pizza.');
print("Total: \$" + orderTotal.toString());

print('\nDo you guys have pineapple pizza?');
if (pizzaPrices.containsKey('pineapple') == false){
print('Pineapple Pizza is not on the menu');
};

}
5 changes: 5 additions & 0 deletions SetandMaps/bin/setsandMaps.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import 'package:SetandMaps/setsandMaps.dart' as setsandMaps;

void main(List<String> arguments) {
print('Hello world: ${setsandMaps.calculate()}!');
}
3 changes: 3 additions & 0 deletions SetandMaps/lib/setsandMaps.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
int calculate() {
return 6 * 7;
}