Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
Simmitive_Chris_Crook
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chris.crook
Simmitive_Chris_Crook
Commits
16f8e758
Commit
16f8e758
authored
Apr 22, 2021
by
chris.crook
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
> checkout screen works
parent
6fe99650
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
168 additions
and
22 deletions
+168
-22
AdminMenu.java
...ain/java/com/example/summative_chris_crook/AdminMenu.java
+13
-0
BookingDetails.java
...ava/com/example/summative_chris_crook/BookingDetails.java
+10
-10
CheckoutScreen.java
...ava/com/example/summative_chris_crook/CheckoutScreen.java
+114
-9
UserMenu.java
...main/java/com/example/summative_chris_crook/UserMenu.java
+14
-0
activity_checkout_screen.xml
app/src/main/res/layout/activity_checkout_screen.xml
+16
-2
activity_register_page.xml
app/src/main/res/layout/activity_register_page.xml
+1
-1
No files found.
app/src/main/java/com/example/summative_chris_crook/AdminMenu.java
View file @
16f8e758
...
...
@@ -118,6 +118,19 @@ public class AdminMenu extends AppCompatActivity {
}
public
void
goback
(
View
view
){
String
filename6
=
"Booking"
;
File
file6
;
file6
=
new
File
(
getApplicationContext
().
getFilesDir
(),
filename6
+
".txt"
);
try
{
FileWriter
stream
=
new
FileWriter
(
file6
,
false
);
stream
.
append
(
""
);
stream
.
close
();
Toast
.
makeText
(
getApplicationContext
(),
"Logged out, cart contents wiped"
,
Toast
.
LENGTH_LONG
).
show
();
}
catch
(
Exception
e
){
Toast
.
makeText
(
getApplicationContext
(),
"Internal File Error"
,
Toast
.
LENGTH_LONG
).
show
();
}
Intent
intent
=
new
Intent
(
this
,
MainActivity
.
class
);
startActivity
(
intent
);
}
...
...
app/src/main/java/com/example/summative_chris_crook/BookingDetails.java
View file @
16f8e758
...
...
@@ -152,7 +152,7 @@ public class BookingDetails extends AppCompatActivity {
public
void
timeslot1
(
View
view
){
// time slot 1
String
tempwrite
=
((
EditText
)
findViewById
(
R
.
id
.
YEET2
)).
getText
().
toString
();
tempwrite
+=
"&
1
"
;
tempwrite
+=
"&
9:00-11:00
"
;
String
[]
temploadarray
=
tempwrite
.
split
(
"&"
);
// id,museum_name,city,country,price,name,password,adminflag,currency,language,id,slot
String
filename6
=
"Booking"
;
// + temploadarray[5] + temploadarray [10]; // file will be named: Booking_NameID
File
file6
;
...
...
@@ -186,9 +186,9 @@ public class BookingDetails extends AppCompatActivity {
public
void
timeslot2
(
View
view
){
// time slot 2
String
tempwrite
=
((
EditText
)
findViewById
(
R
.
id
.
YEET2
)).
getText
().
toString
();
tempwrite
+=
"&
2
"
;
tempwrite
+=
"&
11:00-13:00
"
;
String
[]
temploadarray
=
tempwrite
.
split
(
"&"
);
// id,museum_name,city,country,price,name,password,adminflag,currency,language,id
String
filename6
=
"Booking
_"
+
temploadarray
[
5
]
+
temploadarray
[
10
];
// file will be named: Booking_NameID
String
filename6
=
"Booking
"
;
//
+ temploadarray[5] + temploadarray [10]; // file will be named: Booking_NameID
File
file6
;
file6
=
new
File
(
getApplicationContext
().
getFilesDir
(),
filename6
+
".txt"
);
String
temp
=
""
;
...
...
@@ -203,7 +203,7 @@ public class BookingDetails extends AppCompatActivity {
//
}
else
{
tempwrite
=
"
%
"
+
tempwrite
;
tempwrite
=
"
&
"
+
tempwrite
;
}
try
{
FileWriter
stream
=
new
FileWriter
(
file6
,
true
);
...
...
@@ -221,9 +221,9 @@ public class BookingDetails extends AppCompatActivity {
public
void
timeslot3
(
View
view
){
// time slot 3
String
tempwrite
=
((
EditText
)
findViewById
(
R
.
id
.
YEET2
)).
getText
().
toString
();
tempwrite
+=
"&
3
"
;
tempwrite
+=
"&
13:00-15:00
"
;
String
[]
temploadarray
=
tempwrite
.
split
(
"&"
);
// id,museum_name,city,country,price,name,password,adminflag,currency,language,id
String
filename6
=
"Booking
_"
+
temploadarray
[
5
]
+
temploadarray
[
10
];
// file will be named: Booking_NameID
String
filename6
=
"Booking
"
;
//
+ temploadarray[5] + temploadarray [10]; // file will be named: Booking_NameID
File
file6
;
file6
=
new
File
(
getApplicationContext
().
getFilesDir
(),
filename6
+
".txt"
);
String
temp
=
""
;
...
...
@@ -238,7 +238,7 @@ public class BookingDetails extends AppCompatActivity {
//
}
else
{
tempwrite
=
"
%
"
+
tempwrite
;
tempwrite
=
"
&
"
+
tempwrite
;
}
try
{
FileWriter
stream
=
new
FileWriter
(
file6
,
true
);
...
...
@@ -255,9 +255,9 @@ public class BookingDetails extends AppCompatActivity {
public
void
timeslot4
(
View
view
){
// time slot 4
String
tempwrite
=
((
EditText
)
findViewById
(
R
.
id
.
YEET2
)).
getText
().
toString
();
tempwrite
+=
"&
4
"
;
tempwrite
+=
"&
15:00-17:00
"
;
String
[]
temploadarray
=
tempwrite
.
split
(
"&"
);
// id,museum_name,city,country,price,name,password,adminflag,currency,language,id
String
filename6
=
"Booking
_"
+
temploadarray
[
5
]
+
temploadarray
[
10
];
// file will be named: Booking_NameID
String
filename6
=
"Booking
"
;
//
+ temploadarray[5] + temploadarray [10]; // file will be named: Booking_NameID
File
file6
;
file6
=
new
File
(
getApplicationContext
().
getFilesDir
(),
filename6
+
".txt"
);
String
temp
=
""
;
...
...
@@ -272,7 +272,7 @@ public class BookingDetails extends AppCompatActivity {
//
}
else
{
tempwrite
=
"
%
"
+
tempwrite
;
tempwrite
=
"
&
"
+
tempwrite
;
}
try
{
FileWriter
stream
=
new
FileWriter
(
file6
,
true
);
...
...
app/src/main/java/com/example/summative_chris_crook/CheckoutScreen.java
View file @
16f8e758
...
...
@@ -8,8 +8,10 @@ import android.view.View;
import
android.widget.Button
;
import
android.widget.EditText
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
java.io.File
;
import
java.io.FileWriter
;
import
java.util.Scanner
;
public
class
CheckoutScreen
extends
AppCompatActivity
{
...
...
@@ -19,6 +21,10 @@ public class CheckoutScreen extends AppCompatActivity {
File
file1
;
File
file2
;
Double
Euro
=
1.16
;
Double
USD
=
1.40
;
Double
HKD
=
10.85
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
...
...
@@ -69,15 +75,21 @@ public class CheckoutScreen extends AppCompatActivity {
}
}
catch
(
Exception
e
)
{
}
// id,museum_name,city,country,price,name,password,adminflag,currency,language,id,slot
int
idint
=
read
.
hashCode
();
if
(
idint
<
0
){
idint
*=-
1
;
}
int
totalprice
=
0
;
int
idint2
=
(
int
)
Math
.
round
(
Math
.
random
()
*
(
999999
-
100000
+
1
)
+
100000
);
String
[]
loadbooking
=
read
.
split
(
"&"
);
String
bookingoutput
=
"
Bookings made:
"
;
String
bookingoutput
=
"
Cart ID: "
+
idint2
+
"\nBookings made:\n>
"
;
for
(
int
i
=
0
;
i
<
loadbooking
.
length
;
i
++){
if
(
i
%
12
==
2
){
if
(
i
%
12
==
1
){
//museum name
bookingoutput
+=
loadbooking
[
i
];
bookingoutput
+=
", "
;
}
if
(
i
%
12
==
3
){
if
(
i
%
12
==
2
){
//city
bookingoutput
+=
"("
;
bookingoutput
+=
loadbooking
[
i
];
...
...
@@ -86,26 +98,96 @@ public class CheckoutScreen extends AppCompatActivity {
if
(
i
%
12
==
9
){
//currency mode to select
}
if
(
i
%
12
==
5
){
if
(
i
%
12
==
4
){
//price
totalprice
+=
Integer
.
parseInt
(
loadbooking
[
i
]);
bookingoutput
+=
" "
;
String
pricetest
=
loadbooking
[
i
+
4
];
int
price
=
0
;
bookingoutput
+=
loadbooking
[
i
];
if
(
temploadarray
[
3
].
equals
(
"£"
)){
bookingoutput
+=
"£"
;
bookingoutput
+=
loadbooking
[
i
];
}
if
(
temploadarray
[
3
].
equals
(
"€"
)){
bookingoutput
+=
"€"
;
double
price
=
Double
.
parseDouble
(
loadbooking
[
i
]);
price
*=
Euro
;
bookingoutput
+=
price
;
bookingoutput
+=
"(£"
;
bookingoutput
+=
loadbooking
[
i
];
bookingoutput
+=
")"
;
}
if
(
temploadarray
[
3
].
equals
(
"US$"
)){
bookingoutput
+=
"$"
;
double
price
=
Double
.
parseDouble
(
loadbooking
[
i
]);
price
*=
USD
;
bookingoutput
+=
price
;
bookingoutput
+=
"(£"
;
bookingoutput
+=
loadbooking
[
i
];
bookingoutput
+=
")"
;
}
if
(
temploadarray
[
3
].
equals
(
"HK$"
)){
bookingoutput
+=
"$"
;
double
price
=
Double
.
parseDouble
(
loadbooking
[
i
]);
price
*=
HKD
;
bookingoutput
+=
price
;
bookingoutput
+=
"(£"
;
bookingoutput
+=
loadbooking
[
i
];
bookingoutput
+=
")"
;
}
double
price
=
0
;
//bookingoutput += loadbooking [i];
bookingoutput
+=
", "
;
}
if
(
i
%
12
==
1
0
){
//
if
(
i
%
12
==
1
1
){
//
time slot
bookingoutput
+=
loadbooking
[
i
];
bookingoutput
+=
", "
;
}
if
(
i
%
12
==
0
){
//end of each booking entry
bookingoutput
+=
loadbooking
[
i
];
//
bookingoutput += loadbooking [i];
bookingoutput
+=
"\n"
;
bookingoutput
+=
"> "
;
}
}
bookingoutput
+=
"\n\nOther Items:\n>"
;
bookingoutput
+=
"\n\nTotal: "
;
if
(
temploadarray
[
3
].
equals
(
"£"
)){
bookingoutput
+=
"£"
;
}
if
(
temploadarray
[
3
].
equals
(
"€"
)){
bookingoutput
+=
"€"
;
double
price
=
Double
.
parseDouble
(
String
.
valueOf
(
totalprice
));
price
*=
Euro
;
price
=
Math
.
round
(
price
*
100.0
)
/
100.0
;
bookingoutput
+=
price
;
bookingoutput
+=
"(£"
;
bookingoutput
+=
totalprice
;
bookingoutput
+=
")"
;
}
if
(
temploadarray
[
3
].
equals
(
"US$"
)){
bookingoutput
+=
"$"
;
double
price
=
Double
.
parseDouble
(
String
.
valueOf
(
totalprice
));
price
*=
USD
;
price
=
Math
.
round
(
price
*
100.0
)
/
100.0
;
bookingoutput
+=
price
;
bookingoutput
+=
"(£"
;
bookingoutput
+=
totalprice
;
bookingoutput
+=
")"
;
}
if
(
temploadarray
[
3
].
equals
(
"HK$"
)){
bookingoutput
+=
"$"
;
double
price
=
Double
.
parseDouble
(
String
.
valueOf
(
totalprice
));
price
*=
HKD
;
price
=
Math
.
round
(
price
*
100.0
)
/
100.0
;
bookingoutput
+=
price
;
bookingoutput
+=
"(£"
;
bookingoutput
+=
totalprice
;
bookingoutput
+=
")"
;
}
bookingoutput
+=
" All Prices Billed in GBP (£)"
;
((
EditText
)
findViewById
(
R
.
id
.
outputcheckout
)).
setText
(
bookingoutput
);
}
...
...
@@ -149,4 +231,27 @@ public class CheckoutScreen extends AppCompatActivity {
Intent
intent
=
new
Intent
(
this
,
MainBookingPage
.
class
);
startActivity
(
intent
);
}
public
void
IThrewItOnTheGround
(
View
view
){
//empty basket
String
filename6
=
"Booking"
;
File
file6
;
file6
=
new
File
(
getApplicationContext
().
getFilesDir
(),
filename6
+
".txt"
);
try
{
FileWriter
stream
=
new
FileWriter
(
file6
,
false
);
stream
.
append
(
""
);
stream
.
close
();
Toast
.
makeText
(
getApplicationContext
(),
"Cart contents wiped"
,
Toast
.
LENGTH_LONG
).
show
();
}
catch
(
Exception
e
){
Toast
.
makeText
(
getApplicationContext
(),
"Internal File Error"
,
Toast
.
LENGTH_LONG
).
show
();
}
Intent
intent
=
new
Intent
(
this
,
CheckoutScreen
.
class
);
startActivity
(
intent
);
}
public
void
ChaChing
(
View
view
){
//buy
}
}
\ No newline at end of file
app/src/main/java/com/example/summative_chris_crook/UserMenu.java
View file @
16f8e758
...
...
@@ -10,6 +10,7 @@ import android.widget.TextView;
import
android.widget.Toast
;
import
java.io.File
;
import
java.io.FileWriter
;
import
java.util.Scanner
;
public
class
UserMenu
extends
AppCompatActivity
{
...
...
@@ -90,6 +91,19 @@ public class UserMenu extends AppCompatActivity {
}
public
void
goback
(
View
view
){
String
filename6
=
"Booking"
;
File
file6
;
file6
=
new
File
(
getApplicationContext
().
getFilesDir
(),
filename6
+
".txt"
);
try
{
FileWriter
stream
=
new
FileWriter
(
file6
,
false
);
stream
.
append
(
""
);
stream
.
close
();
Toast
.
makeText
(
getApplicationContext
(),
"Logged out, cart contents wiped"
,
Toast
.
LENGTH_LONG
).
show
();
}
catch
(
Exception
e
){
Toast
.
makeText
(
getApplicationContext
(),
"Internal File Error"
,
Toast
.
LENGTH_LONG
).
show
();
}
Intent
intent
=
new
Intent
(
this
,
MainActivity
.
class
);
startActivity
(
intent
);
}
...
...
app/src/main/res/layout/activity_checkout_screen.xml
View file @
16f8e758
...
...
@@ -41,11 +41,25 @@
android:onClick=
"toshop"
android:text=
"Shop"
/>
<Button
android:id=
"@+id/button81"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:onClick=
"IThrewItOnTheGround"
android:text=
"Clear Basket"
/>
<Button
android:id=
"@+id/button82"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:onClick=
"ChaChing"
android:text=
"Buy"
/>
<EditText
android:id=
"@+id/outputcheckout"
android:layout_width=
"match_parent"
android:layout_height=
"
523
dp"
android:layout_height=
"
429
dp"
android:ems=
"10"
android:inputType=
"text
PersonNam
e"
/>
android:inputType=
"text
LongMessage|textMultiLin
e"
/>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
app/src/main/res/layout/activity_register_page.xml
View file @
16f8e758
...
...
@@ -124,7 +124,7 @@
android:id=
"@+id/textView26"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:text=
"Default Currency"
/>
android:text=
"Default Currency
(display only, transactions are in £)
"
/>
<LinearLayout
android:layout_width=
"match_parent"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment