Commit b4f8f212 authored by christopher.foster's avatar christopher.foster

Final product

parent 0a4a6166
...@@ -9,7 +9,8 @@ ...@@ -9,7 +9,8 @@
android:roundIcon="@mipmap/ic_launcher_round" android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/AppTheme"> android:theme="@style/AppTheme">
<activity android:name=".reviewToy"></activity> <activity android:name=".reciept"></activity>
<activity android:name=".reviewToy" />
<activity android:name=".reviewBenz" /> <activity android:name=".reviewBenz" />
<activity android:name=".reviewHon" /> <activity android:name=".reviewHon" />
<activity android:name=".reviewJag" /> <activity android:name=".reviewJag" />
......
...@@ -13,13 +13,15 @@ import java.util.Random; ...@@ -13,13 +13,15 @@ import java.util.Random;
public class orderDetails extends AppCompatActivity { public class orderDetails extends AppCompatActivity {
public double refreshment = 0; public double refreshment = 0;
public String refresh = ""; public static String refresh = "";
private boolean disc = false; private boolean disc = false;
public int discount = 0; public static int discount = 0;
private int hours = 0; private int hours = 0;
private int refreshNo = 0; private int refreshNo = 0;
public double total = 0; public static double total = 0;
public String cost = ""; public static String cost = "";
public static double carCost = 0;
public static double refreshCost = 0;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
...@@ -69,18 +71,8 @@ public class orderDetails extends AppCompatActivity { ...@@ -69,18 +71,8 @@ public class orderDetails extends AppCompatActivity {
} }
public void calculateCost (View v) public void calculateCost (View v)
{ {
//EditText car = (EditText) findViewById(R.id.carChoice);
/*
EditText editText=findViewById(R.id.editText);
String temp=editText.getText().toString();
int value=0;
if (!“”.equals(temp)){
value=Integer.parseInt(temp);
}
*/
EditText hour = (EditText) findViewById(R.id.hours); EditText hour = (EditText) findViewById(R.id.hours);
String temp = hour.getText().toString(); String temp = hour.getText().toString();
if(!"".equals(temp)) if(!"".equals(temp))
...@@ -123,15 +115,16 @@ if (!“”.equals(temp)){ ...@@ -123,15 +115,16 @@ if (!“”.equals(temp)){
break; break;
} }
carCost = total;
refreshCost = (refreshment * refreshNo);
total = total + (refreshment * refreshNo); total = total + (refreshment * refreshNo);
total = total -((total / 100)*discount); total = total -((total / 100)*discount);
cost = Double.toString(total); cost = Double.toString(total);
Toast.makeText(getApplicationContext(), "Cost" + cost, Toast.LENGTH_LONG).show(); Toast.makeText(getApplicationContext(), "Cost" + cost, Toast.LENGTH_LONG).show();
Intent list = new Intent(this, Carlist.class); Intent reciept = new Intent(this, reciept.class);
startActivity(list); startActivity(reciept);
} }
......
package com.example.assignment;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
public class reciept extends AppCompatActivity {
private double payment = 0;
private double change = 0;
private boolean paid = false;
private String moneyBack = "0";
private String refCost = "0";
private String discount = "0";
private String carCost = "0";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_reciept);
TextView total = (TextView)findViewById(R.id.totalCost);
total.setText(orderDetails.cost);
carCost = Double.toString(orderDetails.carCost);
TextView cost = (TextView)findViewById(R.id.carCost);
cost.setText(carCost);
refCost = Double.toString(orderDetails.refreshCost);
TextView refresh = (TextView)findViewById(R.id.refreshCost);
refresh.setText(refCost);
discount = Integer.toString(orderDetails.discount);
TextView disc = (TextView)findViewById(R.id.percentage);
disc.setText(discount);
TextView refreshment = (TextView)findViewById(R.id.refreshReciept);
refreshment.setText(orderDetails.refresh);
TextView car = (TextView)findViewById(R.id.receiptCar);
car.setText(carPurchase.choice);
}
public void payment(View v)
{
EditText pay = (EditText) findViewById(R.id.pay);
String temp = pay.getText().toString();
if(!"".equals(temp))
{
payment = Double.parseDouble(temp);
}
if (payment < orderDetails.total)
{
Toast.makeText(getApplicationContext(), "Please enter the full amount or more", Toast.LENGTH_LONG).show();
}
else {
change = payment - orderDetails.total;
moneyBack = Double.toString(change);
TextView Change = (TextView) findViewById(R.id.change);
Change.setText(moneyBack);
paid = true;
}
}
public void carList(View v)
{
if (paid) {
Intent I = new Intent(this, Carlist.class);
startActivity(I);
}
else
{
Toast.makeText(getApplicationContext(), "Please pay fisrt", Toast.LENGTH_LONG).show();
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".reciept">
<TextView
android:id="@+id/textView40"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="130dp"
android:layout_marginLeft="130dp"
android:layout_marginTop="20dp"
android:text="Reciept"
android:textColor="#000"
android:textSize="40sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/receiptCar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="40dp"
android:layout_marginLeft="40dp"
android:layout_marginTop="30dp"
android:text="placeholder"
android:textColor="#000"
android:textSize="20sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView40" />
<TextView
android:id="@+id/carCost"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:layout_marginEnd="40dp"
android:layout_marginRight="40dp"
android:text="cost"
android:textColor="#000"
android:textSize="20sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView40" />
<TextView
android:id="@+id/refreshReciept"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="40dp"
android:layout_marginLeft="40dp"
android:layout_marginTop="20dp"
android:text="Placeholder"
android:textColor="#000"
android:textSize="20sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/receiptCar" />
<TextView
android:id="@+id/refreshCost"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginEnd="40dp"
android:layout_marginRight="40dp"
android:text="cost"
android:textColor="#000"
android:textSize="20sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/carCost" />
<TextView
android:id="@+id/textView45"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="40dp"
android:layout_marginLeft="40dp"
android:layout_marginTop="20dp"
android:text="Discount"
android:textColor="#000"
android:textSize="20sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/refreshReciept" />
<TextView
android:id="@+id/textView46"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="40dp"
android:layout_marginLeft="40dp"
android:layout_marginTop="20dp"
android:text="Total"
android:textColor="#000"
android:textSize="20sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView45" />
<Button
android:id="@+id/carListbtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="161dp"
android:layout_marginRight="161dp"
android:layout_marginBottom="180dp"
android:onClick="carList"
android:text="carList"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
<TextView
android:id="@+id/percentage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginEnd="40dp"
android:layout_marginRight="40dp"
android:text="cost"
android:textColor="#000"
android:textSize="20sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/refreshCost" />
<TextView
android:id="@+id/totalCost"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginEnd="40dp"
android:layout_marginRight="40dp"
android:text="cost"
android:textColor="#000"
android:textSize="20sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/percentage" />
<TextView
android:id="@+id/textView49"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="75dp"
android:layout_marginLeft="75dp"
android:layout_marginTop="20dp"
android:text="Payment"
android:textColor="#000"
android:textSize="20sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView46" />
<TextView
android:id="@+id/textView50"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="83dp"
android:layout_marginLeft="83dp"
android:layout_marginTop="19dp"
android:text="Change"
android:textColor="#000"
android:textSize="20sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/pay" />
<TextView
android:id="@+id/change"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="84dp"
android:layout_marginLeft="84dp"
android:layout_marginTop="17dp"
android:text="0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView50" />
<Button
android:id="@+id/payment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="52dp"
android:layout_marginEnd="36dp"
android:layout_marginRight="36dp"
android:onClick="payment"
android:text="Pay"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/totalCost" />
<EditText
android:id="@+id/pay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
android:layout_marginTop="8dp"
android:ems="10"
android:inputType="numberDecimal"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView49" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment