Commit e5e29260 authored by lucy.hemingway's avatar lucy.hemingway

finished - annotations added

parent ff980d43
......@@ -14,6 +14,9 @@ import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
import java.util.List;
//code used from 2CB107 'Week 7 - Evaluating Mobile Applications and Developing App with Recycler'
class adapter extends RecyclerView.Adapter<adapter.ViewHolder> {
private List<MuseumNames> myMuseums;
......@@ -51,6 +54,7 @@ class adapter extends RecyclerView.Adapter<adapter.ViewHolder> {
holder.MuseumText.setOnClickListener(new View.OnClickListener() {
@Override
//go to fulldetails page and send two variables
public void onClick(View v) {
String picked = myMuseums.get(position).price;
Integer priceofticket = Integer.parseInt(price);
......
......@@ -26,6 +26,7 @@ import java.util.Date;
public class Booking extends AppCompatActivity {
//to hold the sent variables
public static Integer price;
public static String selectedMuseum;
......@@ -33,6 +34,7 @@ public class Booking extends AppCompatActivity {
public static String time;
public static String selecteddate;
//buttons and views being used
RadioGroup radiogroup;
RadioButton choose;
TextView text;
......@@ -52,28 +54,31 @@ public class Booking extends AppCompatActivity {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_booking);
// Bundle bundle = getIntent().getExtras();
// Intent intent = getIntent();
// String mname = bundle.getString(fulldetails.selectedMuseum);
// int price = bundle.getInt(String.valueOf(fulldetails.price), 0);
TextView museumname = (TextView)findViewById(R.id.Museumname);
TextView priceofmuseum = (TextView)findViewById(R.id.pricehere);
//get variables
Intent intent = getIntent();
selectedMuseum = intent.getStringExtra("selectedMuseum");
price = intent.getIntExtra("price",0);
//show museum name and price
museumname.setText("Selected Museum: " + selectedMuseum);
priceofmuseum.setText("Price: £" + price);
Date = (TextView) findViewById(R.id.selectdate);
String dateshown = Date.toString();
//code for a date selector
//reference - https://www.youtube.com/watch?v=33BFCdL0Di0 'DatePickerDialog - Android Studio Tutorial
Date.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
......@@ -123,6 +128,7 @@ public class Booking extends AppCompatActivity {
//none selected, tell user to select
Toast.makeText(getApplicationContext(),"Please select a time/date above.", Toast.LENGTH_LONG).show();
}else {
//take variables to next page - cafe
findRadioButton(choosen);
Intent cafe = new Intent (getApplicationContext(), cafe.class);
cafe.putExtra("time",time);
......
package com.example.appppppp;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
public class DetailMuseums extends AppCompatActivity {
@Override
protected void onCreate (Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fulldetails);
Intent intent = getIntent();
String selectedMuseum = intent.getStringExtra("selectedMuseum");
((TextView)findViewById(R.id.check)).setText(selectedMuseum);
//setDetail(selectedMuseum);
}
/* void setDetail(String s){
switch(s) {
case "Louvre":
((ImageView)findViewById(R.id.theimage)).setImageResource(R.drawable.louvre);
((TextView)findViewById(R.id.thetext)).setText( "The Louvre asdaskjhdasdlkasda al s dlasdajsdjasjd jka ");
break;
case "National Museum of China":
((ImageView)findViewById(R.id.theimage)).setImageResource(R.drawable.china);
((TextView)findViewById(R.id.thetext)).setText( "China asdaskjhdasdlkasda al s dlasdajsdjasjd jka ");
break;
case "Vatican Museums":
((ImageView)findViewById(R.id.theimage)).setImageResource(R.drawable.vatican);
((TextView)findViewById(R.id.thetext)).setText( "Vatican d jka ");
break;
case "Metropolitan Museum of Art":
((ImageView)findViewById(R.id.theimage)).setImageResource(R.drawable.metropolitan);
((TextView)findViewById(R.id.thetext)).setText( "The metropolitan asdaskjhdasdlkasda al s dlasdajsdjasjd jka ");
break;
default:
((TextView)findViewById(R.id.thetext)).setText("Not Added");
break;
}
} */
}
......@@ -19,6 +19,8 @@ public class FullPurchase extends AppCompatActivity {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_full_purchase);
//get variables
Intent intent = getIntent();
String museumname = intent.getStringExtra("selectedMuseum");
......@@ -32,15 +34,6 @@ public class FullPurchase extends AppCompatActivity {
//add up to show customer full price they need to pay
int fullprice = priceofticket + totalofcafe + totalofsouvenir;
// museum = findViewById(R.id.museum);
// ticket = findViewById(R.id.ticket);
// cafe = findViewById(R.id.cafe1);
// souvenir = findViewById(R.id.souvenir);
// museum.setText(museumname);
// ticket.setText(String.valueOf(priceofticket));
// cafe.setText(String.valueOf(totalofcafe));
/// souvenir.setText(String.valueOf(totalofsouvenir));
totalprices = findViewById(R.id.receipt);
......@@ -49,10 +42,11 @@ public class FullPurchase extends AppCompatActivity {
next = findViewById(R.id.next);
//go to next page
next.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//send variables
Intent intent = new Intent (getApplicationContext(), Payment.class);
intent.putExtra("fullprice",fullprice);
intent.putExtra("totalsouvenir",totalofsouvenir);
......@@ -68,7 +62,7 @@ public class FullPurchase extends AppCompatActivity {
});
}
//back
public void backone(View view){
Intent intent = new Intent (getApplicationContext(),SouvenirShop.class);
startActivity(intent);
......
......@@ -13,6 +13,8 @@ public class HelpPage extends AppCompatActivity {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_help_page);
}
//back to mainmenu
public void toMenu (View V){
Intent back = new Intent(this, MainMenu.class);
startActivity(back);
......
......@@ -21,6 +21,7 @@ public class LogIn extends AppCompatActivity {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_log_in);
//connect to database
db = new dbconnect(this);
email1 = (EditText)findViewById(R.id.emaillog);
......@@ -28,28 +29,33 @@ public class LogIn extends AppCompatActivity {
login = (Button)findViewById(R.id.loginlog);
//instructions for clicking on log in button
login.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
//get entered details
String email = email1.getText().toString();
String Password = password2.getText().toString();
boolean registered = db.registered(email,Password);
if (registered==true){
//change to go to museum list
//change to go to museum list as the user is registered
//they have also entered correct details
Intent intent = new Intent(LogIn.this, MuseumList.class);
startActivity(intent);
}
else{
//incorrect email or password, tell user to retry
Toast.makeText(getApplicationContext(),"Incorrect Email/Password, try again",Toast.LENGTH_LONG).show();
}
}
});
}
//back
public void backone(View view){
Intent intent = new Intent (getApplicationContext(),MainMenu.class);
startActivity(intent);
......
......@@ -13,6 +13,8 @@ public class MainMenu extends AppCompatActivity {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_menu);
}
//instructions for all buttons to go to new intent
public void toRegister(View V){
Intent Registerpage = new Intent(this,Registration.class );
startActivity(Registerpage);
......
......@@ -17,16 +17,17 @@ public class MuseumList extends AppCompatActivity {
adapter adapterObj;
ArrayList<MuseumNames> dataList;
//code used from 2CB107 'Week 7 - Evaluating Mobile Applications and Developing App with Recycler'
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_museum_list);
Toast.makeText(getApplicationContext(), "Welcome, you are logged in.", Toast.LENGTH_SHORT).show();
// data to populate the recyclerview with
// data for the recycler list
dataList = new ArrayList<>();
//add all ten museums and brief information
dataList.add(new MuseumNames ("Louvre", "10","Paris, France" ));
dataList.add(new MuseumNames ("National Museum of China", "10", "Beijing, China"));
......@@ -47,7 +48,7 @@ public class MuseumList extends AppCompatActivity {
adapterObj = new adapter(this, dataList);
recyclerObj.setAdapter(adapterObj);
}
//back
public void backone(View view){
Intent intent = new Intent (getApplicationContext(),fulldetails.class);
startActivity(intent);
......
......@@ -2,11 +2,12 @@ package com.example.appppppp;
public class MuseumNames {
//allow three inserts per list item, name price and description
String name;
String price;
String desc;
//method to implement
MuseumNames(String n,String p, String d){
name = n;
price = p;
......
......@@ -21,6 +21,7 @@ public class Payment extends AppCompatActivity {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_payment);
//get variables
Intent intent = getIntent();
totalsouvenir = intent.getIntExtra("totalsouvenir",0);
totalcafe = intent.getIntExtra("totalcafe",0);
......@@ -30,10 +31,14 @@ public class Payment extends AppCompatActivity {
price = intent.getIntExtra("fullprice",0);
//change textview to price
pricetopay = findViewById(R.id.fullpriceview);
pricetopay.setText("Total Price = £" + String.valueOf(price));
makepayment = findViewById(R.id.makepayment);
//click make payment - take to new page if amount is the same or above what is needed to pay
makepayment.setOnClickListener(new View.OnClickListener()
{
@Override
......@@ -60,10 +65,12 @@ public class Payment extends AppCompatActivity {
}
public void checkamount(Integer value){
Integer change = 0;
//inserted number is same as the price
if (value == price){
//go to next page - payment worked
Toast.makeText(getApplicationContext(),"You have successfully paid the correct amount",Toast.LENGTH_SHORT).show();
Intent receipt = new Intent (getApplicationContext(), Receipt.class);
receipt.putExtra("pricepaid",value);
......@@ -79,8 +86,9 @@ public class Payment extends AppCompatActivity {
}
else if(value > price){
//user has paid enough, go to next page
change = value - price;
Toast.makeText(getApplicationContext(),"Thankyou for the purchase",Toast.LENGTH_SHORT).show();
Intent receipt = new Intent (getApplicationContext(), Receipt.class);
receipt.putExtra("pricepaid",value);
......@@ -95,10 +103,13 @@ public class Payment extends AppCompatActivity {
}else{
//user has not paid correct amount, stay on page
Toast.makeText(getApplicationContext(),"You have underpaid, please retry payment",Toast.LENGTH_SHORT).show();
}
}
//back
public void backone(View view){
Intent intent = new Intent (getApplicationContext(),fulldetails.class);
startActivity(intent);
......
......@@ -32,18 +32,23 @@ public class Receipt extends AppCompatActivity {
priceofticket = intent.getIntExtra("price",0);
price = intent.getIntExtra("fullprice",0);
//work out the change needed for the customer
int change = value - price;
//random number for their booking number
String bookingid = randombookingnumber();
totalprices = findViewById(R.id.completereceipt);
//print full integers and strings
totalprices.setText("\nMuseum: " + selectedMuseum + "\n\n" + "Date of Visit: " + selecteddate + "\n\n" + "Time Slot: " + time + "\n\n" + "Ticket Price: £" + priceofticket + "\n\n" + "Cafe Total Costs: £" + totalcafe + "\n\n" + "Souvenir Store Total Costs: £" +
totalsouvenir + "\n\n\n" + "Full Price Due: £" + price + "\n\n" + "Price Paid: £" + value + "\n\n" + "Change Due: £" + change + "\n\n\n" + "Your Booking Code (PLEASE RETAIN): " + bookingid);
}
//method for creating a random 6 digit number
// with reference to - https://www.codegrepper.com/code-examples/java/java+random+6+digit+number
public static String randombookingnumber(){
Random nmbr = new Random();
......@@ -53,12 +58,13 @@ public class Receipt extends AppCompatActivity {
return String.format("%06d", booking);
}
//log out to main menu
public void logout(View view){
Intent intent = new Intent (this, MainMenu.class);
startActivity(intent);
}
//go to museum list
public void tomuseums(View view){
Intent intent = new Intent (this, MuseumList.class);
startActivity(intent);
......
......@@ -21,6 +21,7 @@ public class Registration extends AppCompatActivity {
setContentView(R.layout.activity_registration);
db = new dbconnect(this);
//set textviews
text1 = (EditText)findViewById(R.id.email);
text2 = (EditText)findViewById(R.id.pass);
......@@ -28,7 +29,8 @@ public class Registration extends AppCompatActivity {
register = (Button)findViewById(R.id.register);
//click registser button, make sure both passwords are the same
//make sure the email isn't already listed
register.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
......@@ -36,11 +38,13 @@ public class Registration extends AppCompatActivity {
String password = text2.getText().toString();
String repass = text3.getText().toString();
//empty fields
if (email.equals("") || password.equals("") || repass.equals("")) {
Toast.makeText(getApplicationContext(), "One or more missing fields!", Toast.LENGTH_LONG).show();
}
else{
if(password.equals(repass)){
//check email isn't in database
boolean checkE = db.checkE(email);
//add the new user
if(checkE==true){
......@@ -61,12 +65,16 @@ public class Registration extends AppCompatActivity {
}
}
//passwords not matching
else{
Toast.makeText(getApplicationContext(),"Passwords are not the same, retry",Toast.LENGTH_SHORT).show();
}
}
}
});
}
//back
public void backone(View view){
Intent intent = new Intent (getApplicationContext(),MainMenu.class);
startActivity(intent);
......
......@@ -12,6 +12,7 @@ import android.widget.TextView;
import android.widget.Toast;
public class SouvenirShop extends AppCompatActivity {
//variables
public static String selectedMuseum;
public static String time;
public static String selecteddate;
......@@ -27,19 +28,20 @@ public class SouvenirShop extends AppCompatActivity {
setContentView(R.layout.activity_souvenir_shop);
Intent intent = getIntent();
//get variables
totalcafe = intent.getIntExtra("totalcafe",0);
selectedMuseum = intent.getStringExtra("selectedMuseum");
price = intent.getIntExtra("price",0);
time = intent.getStringExtra("time");
selecteddate = intent.getStringExtra("date");
// showtotal = findViewById(R.id.cafe);
//showtotal.setText(String.valueOf(selecteddate));
museumshow = findViewById(R.id.museumshow2);
museumshow.setText(String.valueOf(selectedMuseum));
//identify all spinners being used, and add the array of numbers created in res - values - strings.xml
//reference - https://www.youtube.com/watch?v=on_OrrX7Nw4 'Text Spinner - Android Studio Tutorial'
Spinner spinner8 = findViewById(R.id.spinner8);
ArrayAdapter<String> adapter8 = new ArrayAdapter<String>(SouvenirShop.this, android.R.layout.simple_list_item_1,getResources().getStringArray(R.array.values2));
......@@ -83,7 +85,7 @@ public class SouvenirShop extends AppCompatActivity {
spinner14.setAdapter(adapter14);
purchase = findViewById(R.id.purchase);
//click on purchase decide what happens
purchase.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
......@@ -118,9 +120,7 @@ public class SouvenirShop extends AppCompatActivity {
int totalsouvenir = shirt1 + hat1 + snowglobe1 + keychain1 + bottle1 + mug1 + coaster1;
// Toast.makeText(getApplicationContext(),shirt1 + ", " + hat1, Toast.LENGTH_SHORT).show();
//send variables to next page
Intent next = new Intent (SouvenirShop.this, FullPurchase.class);
next.putExtra("totalsouvenir",totalsouvenir);
next.putExtra("totalcafe",totalcafe);
......@@ -132,7 +132,7 @@ public class SouvenirShop extends AppCompatActivity {
}
});
}
//back
public void backone(View view){
Intent intent = new Intent (getApplicationContext(),cafe.class);
startActivity(intent);
......
......@@ -13,6 +13,8 @@ import android.widget.TextView;
import android.widget.Toast;
public class cafe extends AppCompatActivity implements AdapterView.OnItemSelectedListener {
//variables for sent variables
public static Integer price;
public static String selectedMuseum;
......@@ -36,6 +38,8 @@ public class cafe extends AppCompatActivity implements AdapterView.OnItemSelecte
((TextView)findViewById(R.id.museumshow)).setText(String.valueOf(selectedMuseum));
//identify all spinners being used, and add the array of numbers created in res - values - strings.xml
//reference - https://www.youtube.com/watch?v=on_OrrX7Nw4 'Text Spinner - Android Studio Tutorial'
Spinner spinner = findViewById(R.id.spinner1);
......@@ -81,6 +85,7 @@ public class cafe extends AppCompatActivity implements AdapterView.OnItemSelecte
spinner7.setOnItemSelectedListener(this);
//state what happens when you click the submit button
submit = findViewById(R.id.submitbutton);
submit.setOnClickListener(new View.OnClickListener() {
......@@ -114,10 +119,12 @@ public class cafe extends AppCompatActivity implements AdapterView.OnItemSelecte
sweetroll1 = sweetroll1 * 2;
salad1 = salad1 * 2;
//provide a total for money spent
int totalcafe = tea1 + water1 + coffee1 + flatbread1 + sandwich1 + sweetroll1 + salad1;
// Toast.makeText(getApplicationContext(),salad1 + ", " + sandwich1, Toast.LENGTH_SHORT).show();
//send to next page
Intent Souvenir = new Intent (cafe.this, SouvenirShop.class);
Souvenir.putExtra("totalcafe", totalcafe);
......
......@@ -26,7 +26,8 @@ public class dbconnect extends SQLiteOpenHelper {
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL("drop table if exists users");
}
//code for new user being inserted into the database
//only add if user isn't already in the database
public boolean addnewuser(String email, String password) {
SQLiteDatabase data = this.getWritableDatabase();
......
......@@ -22,38 +22,26 @@ public class fulldetails extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fulldetails);
//get variables and set
Intent intent = getIntent();
selectedMuseum = intent.getStringExtra("selectedMuseum");
price = intent.getIntExtra("price",0);
((TextView)findViewById(R.id.priceview)).setText(String.valueOf(price));
((TextView)findViewById(R.id.check)).setText(selectedMuseum);
setDetail(selectedMuseum);
// setvariables(selectedMuseum);
setDetail(selectedMuseum);
/* bookthis = (Button)findViewById(R.id.book);
bookthis.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent book = new Intent (getApplicationContext(), Booking.class);
book.putExtra("museum", selectedMuseum);
book.putExtra("fee",price);
startActivity(book);
}
});*/
}
//method to set the detail of the fulldetails page depending on the museum selected
void setDetail(String s){
//add a paragraph and picture per case
switch(s) {
case "Louvre":
......@@ -165,6 +153,7 @@ public class fulldetails extends AppCompatActivity {
}
//go to next page
public void bookthis(View view){
Bundle n = getIntent().getExtras();
......@@ -174,6 +163,7 @@ public class fulldetails extends AppCompatActivity {
startActivity(book);
}
//back
public void backone(View view){
Intent intent = new Intent (getApplicationContext(),MuseumList.class);
startActivity(intent);
......
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