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

Darle-Set-Map #31

Open
wants to merge 2 commits 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
3 changes: 3 additions & 0 deletions SetandMap/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 1.0.0

- Initial version, created by Stagehand
4 changes: 4 additions & 0 deletions SetandMap/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
A simple command-line application.

Created from templates made available by Stagehand under a BSD-style
[license](https://github.com/dart-lang/stagehand/blob/master/LICENSE).
14 changes: 14 additions & 0 deletions SetandMap/SetandMap.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?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$">
<excludeFolder url="file://$MODULE_DIR$/.dart_tool" />
<excludeFolder url="file://$MODULE_DIR$/.pub" />
<excludeFolder url="file://$MODULE_DIR$/build" />
</content>
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Dart SDK" level="project" />
<orderEntry type="library" name="Dart Packages" level="project" />
</component>
</module>
14 changes: 14 additions & 0 deletions SetandMap/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Defines a default set of lint rules enforced for
# projects at Google. For details and rationale,
# see https://github.com/dart-lang/pedantic#enabled-lints.
include: package:pedantic/analysis_options.yaml

# For lint rules and documentation, see http://dart-lang.github.io/linter/lints.
# Uncomment to specify additional rules.
# linter:
# rules:
# - camel_case_types

analyzer:
# exclude:
# - path/to/excluded/files/**
45 changes: 45 additions & 0 deletions SetandMap/bin/SetandMap.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import 'dart:io';
import 'dart:math';

void main(List<String> arguments) {
print('Sets Exercise');

const a = <int>{2, 13, 7, 19, 1, 21};
const b = <int>{19, 7, 2, 18, 4, 1};
var exA = (a.difference(b));
var exB = (b.difference(a));
var unionAB = exA.union(exB);

print("Set a: " + a.toString());
print("Set b: " + b.toString());

print("Set of elements that belong to either 'a' or 'b', but not both are: "+ unionAB.toString());
var sum = unionAB.reduce((a, b) => a + b);
print("The sum of the set is:" + sum.toString());


//----------------

print(' \n \nMaps Exercise');
const pizzaPrices = {
'margherita': 5.5,
'pepperoni': 7.5,
'vegetarian': 6.5,
};
print('Pizza Menu $pizzaPrices');
const order = ['margherita', 'pepperoni', 'vegetarian'];
var total = pizzaPrices['margherita'] + pizzaPrices['pepperoni'];
print('You ordered Margherita Pizza and Pepperoni Pizza.');
print("Your Total: \$" + total.toString());

print('Other pizza?');
var pizza = stdin.readLineSync();
print(pizza);
if (pizza.contains('vegetarian') == true) {
print('Coming!');
}
else {
print(pizza + " pizza is not on the menu");
}
}

19 changes: 19 additions & 0 deletions SetandMap/pubspec.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.3"
pedantic:
dependency: "direct dev"
description:
name: pedantic
url: "https://pub.dartlang.org"
source: hosted
version: "1.9.2"
sdks:
dart: ">=2.8.1 <3.0.0"
13 changes: 13 additions & 0 deletions SetandMap/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: SetandMap
description: A simple command-line application.
# version: 1.0.0
# homepage: https://www.example.com

environment:
sdk: '>=2.8.1 <3.0.0'

#dependencies:
# path: ^1.7.0

dev_dependencies:
pedantic: ^1.9.0
25 changes: 19 additions & 6 deletions activities/activity1/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,43 @@ void main() {

print("Enter First Name: ");
String fn = stdin.readLineSync();
print{"Enter Middle Name"};
String mn= stdin.readLineSync();
print("Enter Last Name: ");
String ln = stdin.readLineSync();
print("Enter Age: ");
String strAge = stdin.readLineSync();
int age = int.parse(strAge);
Person p3 = Person(fn,ln,age);
print(p3.getFullName());
Student p = Student(fn,mn,ln, age);
}

class Person {
static String company = 'ABC Company';
String firstName, lastName;
int age = 18;
String _dept;
class Student {
static String department = 'Computer Science';
String firstName, lastName,middleName;
int age= 18;
String_dept;

String get dept => _dept;

Person(this.firstName, this.lastName, this.age);

String get dept => _dept;

Person(this.firstName, this.lastName, this.age);
Student(this.firstName, this.middleName, this.lastName, this.age);
//named constructor
Person.withLNandAgeOnly(this.lastName, this.age);

Student.withLNandAgeOnly(this.lastName, this.age);

//Person p = Person();
//p.getFullName();
String getFullName() {
return ("$firstName $lastName age is $age");
return ("Hello $firstName $middleName $lastName, $age, from $department department");
}

//Person.getInfo()
Expand All @@ -47,8 +58,10 @@ class Person {
String toString() {
return lastName;
}

class Person{
void setLastName(String lastName) {
this.lastName = lastName;
}
}
}
}
}