-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
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 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
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 | ||
} |
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 |
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()); | ||
} | ||
} |
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> |
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(); | ||
// } | ||
} |