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

Calculator app assignment #8

Open
wants to merge 13 commits into
base: main
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
104 changes: 104 additions & 0 deletions assingment1/courses.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import 'dart:io';

class OpenElective {
var courseCode;
var courseName;

OpenElective(code, name) {
this.courseCode = code;
this.courseName = name;
}

void printEl() {
print('$courseCode $courseName');
}
}

class BranchElective {
var courseCode;
var courseName;
var branch;
var year;

BranchElective(code, name, branch, year) {
this.courseCode = code;
this.courseName = name;
this.branch = branch;
this.year = year;
}

void printEl() {
print('$courseCode $courseName');
}

String branch_read() {
return branch;
}

String year_read() {
return year;
}
}

void add_els(List OpenEls, List BranchEls) {
print('##Add Electives##\n');
print('Enter the type 1. Open \t 2. Branch');
var choice = int.parse(stdin.readLineSync());

if (choice == 1) {
print('Enter Course Name and Code: ');
// var name = stdin.readLineSync();
// var code = stdin.readLineSync();
// OpenEls.add(new OpenElective(code, name));
var details = stdin.readLineSync().split(' ');
OpenEls.add(new OpenElective(details[0], details[1]));
} else {
print('Enter Course Name, Code, branch, year: ');
var details = stdin.readLineSync().split(' ');
BranchEls.add(
new BranchElective(details[0], details[1], details[2], details[3]));
}
}

void view_els(List OpenEls, List BranchEls, branch, year) {
print('View Electives');
print('##Open Electives##\n');

OpenEls.forEach((element) {
element.printEl();
});

print('\n##Branch Electives##\n');
BranchEls.forEach((element) {
if (element.branch_read() == branch && element.year_read() == year) {
element.printEl();
}
});

var c = stdin.readLineSync();
}

void main() {
var OpenEls = new List();
OpenEls.add(new OpenElective('ma101', 'maths1'));
OpenEls.add(new OpenElective('cs202', 'comp1'));
List BranchEls = new List();
BranchEls.add(new BranchElective('ec340', 'COA', 'ec', '2'));
BranchEls.add(new BranchElective('ec344', 'AIC', "ec", '2'));

var isAdmin;
while (true) {
print('\x1B[2J\x1B[0;0H');
print('Enter the user type 1. Admin 2. Student');
isAdmin = int.parse(stdin.readLineSync());

if (isAdmin == 1) {
add_els(OpenEls, BranchEls);
} else {
print('Enter branch and year');
var details = stdin.readLineSync().split(' ');
// print('$details');
view_els(OpenEls, BranchEls, details[0], details[1]);
}
}
}
Binary file added assingment1/courses.exe
Binary file not shown.
46 changes: 46 additions & 0 deletions assingment1/login.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import 'dart:io';

class Users {
var users = [
{'name': 'John', 'password': 'john@1'},
{'name': 'Rob', 'password': 'rob@1'},
{'name': 'Kate', 'password': 'Kate@1'},
{'name': 'admin', 'password': 'admin@1'},
{'name': 'Tohn', 'password': 'tohn@1'}
];

void login() {
print('Login');

stdout.write('Username: ');
String name = stdin.readLineSync();

stdout.write('Password: ');
String password = stdin.readLineSync();

print("\x1B[2J\x1B[0;0H");
print('Signing In...');

sleep(new Duration(seconds: 2));
print("\x1B[2J\x1B[0;0H");

users.forEach((element) {
if (element['name'] == name && element['password'] == password) {
print('$name Login Sucessful!! ');
exit(0);
}
if (element['name'] == name && element['password'] != password) {
print('Wrong Password!!');
exit(0);
}
});

print('No such user exists!');
}
}

void main() {
var obj = new Users();

obj.login();
}
Binary file added assingment1/login.exe
Binary file not shown.
41 changes: 41 additions & 0 deletions assingment2/calculator/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/

# Flutter/Dart/Pub related
**/doc/api/
**/ios/Flutter/.last_build_id
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.packages
.pub-cache/
.pub/
/build/

# Web related
lib/generated_plugin_registrant.dart

# Symbolication related
app.*.symbols

# Obfuscation related
app.*.map.json
10 changes: 10 additions & 0 deletions assingment2/calculator/.metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.

version:
revision: 78910062997c3a836feee883712c241a5fd22983
channel: stable

project_type: app
14 changes: 14 additions & 0 deletions assingment2/calculator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# calculator

A new Flutter project.

## Getting Started

This is a simple calculator with backspace, clear and basic functionality .
It also has a history feature
You cannot add more than one operator at a time.

## Demo

<p align='center'><img src="calculatorDemo.gif" width="250"></p>

11 changes: 11 additions & 0 deletions assingment2/calculator/android/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
gradle-wrapper.jar
/.gradle
/captures/
/gradlew
/gradlew.bat
/local.properties
GeneratedPluginRegistrant.java

# Remember to never publicly share your keystore.
# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
key.properties
63 changes: 63 additions & 0 deletions assingment2/calculator/android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 29

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}

lintOptions {
disable 'InvalidPackage'
}

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.calculator"
minSdkVersion 16
targetSdkVersion 29
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}

buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}

flutter {
source '../..'
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.calculator">
<!-- Flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>
</manifest>
47 changes: 47 additions & 0 deletions assingment2/calculator/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.calculator">
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method.
In most cases you can leave this as-is, but you if you want to provide
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<application
android:name="io.flutter.app.FlutterApplication"
android:label="calculator"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
<!-- Displays an Android View that continues showing the launch screen
Drawable until Flutter paints its first frame, then this splash
screen fades out. A splash screen is useful to avoid any visual
gap between the end of Android's launch screen and the painting of
Flutter's first frame. -->
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="@drawable/launch_background"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.example.calculator

import io.flutter.embedding.android.FlutterActivity

class MainActivity: FlutterActivity() {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@android:color/white" />

<!-- You can insert your own image assets here -->
<!-- <item>
<bitmap
android:gravity="center"
android:src="@mipmap/launch_image" />
</item> -->
</layer-list>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions assingment2/calculator/android/app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Theme applied to the Android Window while the process is starting -->
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
<!-- Show a splash screen on the activity. Automatically removed when
Flutter draws its first frame -->
<item name="android:windowBackground">@drawable/launch_background</item>
</style>
<!-- Theme applied to the Android Window as soon as the process has started.
This theme determines the color of the Android Window while your
Flutter UI initializes, as well as behind your Flutter UI while its
running.

This Theme is only used starting with V2 of Flutter's Android embedding. -->
<style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar">
<item name="android:windowBackground">@android:color/white</item>
</style>
</resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.calculator">
<!-- Flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>
</manifest>
Loading