Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
sbphantom committed Apr 12, 2024
0 parents commit 265304f
Show file tree
Hide file tree
Showing 90 changed files with 3,988 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
local.properties
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions .idea/deploymentTargetDropDown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/migrations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
47 changes: 47 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
plugins {
alias(libs.plugins.androidApplication)
}

android {
namespace 'neilson.cafe'
compileSdk 34

defaultConfig {
applicationId "neilson.cafe"
minSdk 29
targetSdk 34
versionCode 1
versionName "1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
buildFeatures {
viewBinding true
}
}

dependencies {

implementation libs.appcompat
implementation libs.material
implementation libs.activity
implementation libs.constraintlayout
implementation libs.lifecycle.livedata.ktx
implementation libs.lifecycle.viewmodel.ktx
implementation libs.navigation.fragment
implementation libs.navigation.ui
testImplementation libs.junit
androidTestImplementation libs.ext.junit
androidTestImplementation libs.espresso.core
}
21 changes: 21 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
26 changes: 26 additions & 0 deletions app/src/androidTest/java/neilson/cafe/ExampleInstrumentedTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package neilson.cafe;

import android.content.Context;

import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.*;

/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("neilson.cafe", appContext.getPackageName());
}
}
42 changes: 42 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="neilson.cafe" >

<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Cafe"
tools:targetApi="31" >
<activity
android:name=".CafeViewController"
android:exported="true" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".CoffeeViewController"
android:parentActivityName=".CafeViewController" />
<activity
android:name=".DonutViewController"
android:parentActivityName=".CafeViewController" />
<activity
android:name=".SandwichViewController"
android:parentActivityName=".CafeViewController" />
<activity
android:name=".CartViewController"
android:parentActivityName=".CafeViewController" />
<activity
android:name=".HistoryViewController"
android:parentActivityName=".CafeViewController" />
</application>

</manifest>
142 changes: 142 additions & 0 deletions app/src/main/java/neilson/cafe/CafeMain.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
package neilson.cafe;

import android.os.Bundle;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

//import javafx.application.Application;
//import javafx.fxml.FXMLLoader;
//import javafx.scene.Scene;
//import javafx.stage.Stage;

import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.Random;

/**
* Main Model of Neilson Cafe ordering software
*
* @author Danny Onuorah
*/
public class CafeMain {
private static CafeMain main;
private LinkedHashMap<Integer, Order> orderHistory = new LinkedHashMap<>();
private Order currentOrder;

private CafeMain(){}

public static CafeMain getInstance() {
if (main == null) {
synchronized (CafeMain.class) {
if (main == null) {
main = new CafeMain();
}
}
}
return main;
}

/**
* Get order history
*
* @return transaction history
*/
public LinkedHashMap<Integer, Order> getOrderHistory() {
return orderHistory;
}

/**
* Get current Order
*
* @return current order
*/
public Order getCurrentOrder() {
return currentOrder;
}

/**
* Creates an order with a random order number
**/
public void createOrder() {
Random rand = new Random();
int id;
do id = rand.nextInt(9000) + 1000;
while (orderHistory.containsKey(id));
currentOrder = new Order(id);
}

/**
* Places the current order amd setups the next order
*
* @return true if successfully added order
*/
public boolean addOrder() {
if (currentOrder.cartSize() > 0) {
orderHistory.put(currentOrder.getOrderNumber(), currentOrder);
createOrder();
return true;
}
return false;
}

/**
* Remove a previously placed order
*/
public void removeOrder(int orderNumber) {
orderHistory.remove(orderNumber);
}

/**
* Add item and quantity to the current order cart
*
* @return true is successfully added
*/
public boolean addItem(MenuItem item, int quantity) {
return currentOrder.addItem(item, quantity);
}

/**
* Remove item and quantity to the current order cart
*
* @return true is successfully removed
*/
public boolean removeItem(MenuItem item, int quantity) {

return currentOrder.removeItem(item, quantity);
}


/**
* Starts the controller class
*/
// @Override
// public void start(Stage stage) throws IOException {
// FXMLLoader fxmlLoader = new FXMLLoader(CafeMain.class.getResource("cafe-view.fxml"));
// Scene scene = new Scene(fxmlLoader.load(), 540, 320);
// CafeViewController cafeController = fxmlLoader.getController();
// cafeController.setPrimaryStage(stage, this);
// stage.setTitle("Neilson Cafe");
// stage.setScene(scene);
// stage.setResizable(false);
// stage.show();
//
// createOrder();
// }






/**
* Software entry point
*/
// public static void main(String[] args) {
// launch();
// }
}
Loading

0 comments on commit 265304f

Please sign in to comment.