Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CarRental_Christopher_Foster
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
christopher.foster
CarRental_Christopher_Foster
Commits
7f3cc3eb
Commit
7f3cc3eb
authored
May 15, 2020
by
christopher.foster
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Can purchase and return cars
parent
05ac3b73
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
319 additions
and
24 deletions
+319
-24
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+2
-1
Carlist.java
app/src/main/java/com/example/assignment/Carlist.java
+5
-0
carPurchase.java
app/src/main/java/com/example/assignment/carPurchase.java
+137
-23
orderDetails.java
app/src/main/java/com/example/assignment/orderDetails.java
+3
-0
returnCar.java
app/src/main/java/com/example/assignment/returnCar.java
+104
-0
activity_carlist.xml
app/src/main/res/layout/activity_carlist.xml
+12
-0
activity_return_car.xml
app/src/main/res/layout/activity_return_car.xml
+56
-0
No files found.
app/src/main/AndroidManifest.xml
View file @
7f3cc3eb
...
@@ -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=
".orderDetails"
></activity>
<activity
android:name=
".returnCar"
></activity>
<activity
android:name=
".orderDetails"
/>
<activity
android:name=
".carPurchase"
/>
<activity
android:name=
".carPurchase"
/>
<activity
android:name=
".Carlist"
/>
<activity
android:name=
".Carlist"
/>
<activity
android:name=
".login"
/>
<activity
android:name=
".login"
/>
...
...
app/src/main/java/com/example/assignment/Carlist.java
View file @
7f3cc3eb
...
@@ -18,4 +18,9 @@ public class Carlist extends AppCompatActivity {
...
@@ -18,4 +18,9 @@ public class Carlist extends AppCompatActivity {
Intent
orderScreen
=
new
Intent
(
this
,
carPurchase
.
class
);
Intent
orderScreen
=
new
Intent
(
this
,
carPurchase
.
class
);
startActivity
(
orderScreen
);
startActivity
(
orderScreen
);
}
}
public
void
carReturn
(
View
v
)
{
Intent
I
=
new
Intent
(
this
,
returnCar
.
class
);
startActivity
(
I
);
}
}
}
app/src/main/java/com/example/assignment/carPurchase.java
View file @
7f3cc3eb
...
@@ -6,15 +6,17 @@ import android.content.Intent;
...
@@ -6,15 +6,17 @@ import android.content.Intent;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.view.View
;
import
android.view.View
;
import
android.widget.EditText
;
import
android.widget.EditText
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
android.widget.Toast
;
public
class
carPurchase
extends
AppCompatActivity
{
public
class
carPurchase
extends
AppCompatActivity
{
private
boolean
benz
=
false
;
public
static
boolean
benz
=
false
;
private
boolean
toyota
=
false
;
public
static
boolean
toyota
=
false
;
private
boolean
honda
=
false
;
public
static
boolean
honda
=
false
;
private
boolean
jaguar
=
false
;
public
static
boolean
jaguar
=
false
;
private
boolean
audi
=
false
;
public
static
boolean
audi
=
false
;
private
boolean
valid
=
false
;
private
String
test
=
"not working"
;
private
String
test
=
"not working"
;
public
static
String
choice
=
""
;
public
static
String
choice
=
""
;
...
@@ -24,48 +26,160 @@ public class carPurchase extends AppCompatActivity {
...
@@ -24,48 +26,160 @@ public class carPurchase extends AppCompatActivity {
super
.
onCreate
(
savedInstanceState
);
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_car_purchase
);
setContentView
(
R
.
layout
.
activity_car_purchase
);
Toast
.
makeText
(
getApplicationContext
(),
"working"
,
Toast
.
LENGTH_LONG
);
Toast
.
makeText
(
getApplicationContext
(),
"working"
,
Toast
.
LENGTH_LONG
);
updateStatus
();
}
}
public
void
updateStatus
()
{
TextView
Benz
=
(
TextView
)
findViewById
(
R
.
id
.
benzStat
);
TextView
Toy
=
(
TextView
)
findViewById
(
R
.
id
.
toyStat
);
TextView
Hon
=
(
TextView
)
findViewById
(
R
.
id
.
honStat
);
TextView
Jag
=
(
TextView
)
findViewById
(
R
.
id
.
jagStat
);
TextView
Audi
=
(
TextView
)
findViewById
(
R
.
id
.
audiStat
);
if
(
benz
==
false
)
{
Benz
.
setText
(
"Available"
);
}
else
if
(
benz
==
true
)
{
Benz
.
setText
(
"Unavailable"
);
}
if
(
toyota
==
false
)
{
Toy
.
setText
(
"Available"
);
}
else
if
(
toyota
==
true
)
{
Toy
.
setText
(
"Unavailable"
);
}
if
(
honda
==
false
)
{
Hon
.
setText
(
"Available"
);
}
else
if
(
honda
==
true
)
{
Hon
.
setText
(
"Unavailable"
);
}
if
(
jaguar
==
false
)
{
Jag
.
setText
(
"Available"
);
}
else
if
(
jaguar
==
true
)
{
Jag
.
setText
(
"Unavailable"
);
}
if
(
audi
==
false
)
{
Audi
.
setText
(
"Available"
);
}
else
if
(
audi
==
true
)
{
Audi
.
setText
(
"Unavailable"
);
}
}
public
void
carSelect
(
View
v
)
public
void
carSelect
(
View
v
)
{
{
EditText
car
=
(
EditText
)
findViewById
(
R
.
id
.
carChoice
);
EditText
car
=
(
EditText
)
findViewById
(
R
.
id
.
carChoice
);
String
carName
=
car
.
getText
().
toString
();
String
carName
=
car
.
getText
().
toString
();
TextView
Benz
=
(
TextView
)
findViewById
(
R
.
id
.
benzStat
);
TextView
Toy
=
(
TextView
)
findViewById
(
R
.
id
.
toyStat
);
TextView
Hon
=
(
TextView
)
findViewById
(
R
.
id
.
honStat
);
TextView
Jag
=
(
TextView
)
findViewById
(
R
.
id
.
jagStat
);
TextView
Audi
=
(
TextView
)
findViewById
(
R
.
id
.
audiStat
);
if
(
carName
.
toLowerCase
().
equals
(
"audi"
))
if
(
carName
.
toLowerCase
().
equals
(
"audi"
))
{
{
audi
=
true
;
if
(
audi
==
false
)
{
test
=
"working"
;
audi
=
true
;
choice
=
"audi"
;
test
=
"working"
;
valid
=
true
;
choice
=
"audi"
;
Audi
.
setText
(
"unavailable"
);
}
else
if
(
audi
==
true
)
{
valid
=
false
;
}
}
}
else
if
(
carName
.
toLowerCase
().
equals
(
"toyota"
))
else
if
(
carName
.
toLowerCase
().
equals
(
"toyota"
))
{
{
test
=
"working"
;
if
(
toyota
==
false
)
{
toyota
=
true
;
test
=
"working"
;
choice
=
"toyota"
;
toyota
=
true
;
valid
=
true
;
choice
=
"toyota"
;
Toy
.
setText
(
"unavailable"
);
}
else
if
(
toyota
==
true
)
{
valid
=
false
;
}
}
}
else
if
(
carName
.
toLowerCase
().
equals
(
"honda"
))
else
if
(
carName
.
toLowerCase
().
equals
(
"honda"
))
{
{
test
=
"working"
;
if
(
honda
==
false
)
{
honda
=
true
;
test
=
"working"
;
choice
=
"honda"
;
honda
=
true
;
valid
=
true
;
choice
=
"honda"
;
Hon
.
setText
(
"unavailable"
);
}
else
if
(
honda
==
true
)
{
valid
=
false
;
}
}
}
else
if
(
carName
.
toLowerCase
().
equals
(
"jaguar"
))
else
if
(
carName
.
toLowerCase
().
equals
(
"jaguar"
))
{
{
test
=
"working"
;
if
(
jaguar
==
false
)
{
jaguar
=
true
;
choice
=
"jaguar"
;
test
=
"working"
;
jaguar
=
true
;
valid
=
true
;
choice
=
"jaguar"
;
Jag
.
setText
(
"unavailable"
);
}
else
if
(
jaguar
==
true
)
{
valid
=
false
;
}
}
}
else
if
(
carName
.
toLowerCase
().
equals
(
"benz"
))
else
if
(
carName
.
toLowerCase
().
equals
(
"benz"
))
{
{
test
=
"working"
;
if
(
benz
==
false
)
{
jaguar
=
true
;
test
=
"working"
;
choice
=
"benz"
;
benz
=
true
;
valid
=
true
;
choice
=
"benz"
;
Benz
.
setText
(
"Unavailable"
);
}
else
if
(
benz
==
true
)
{
valid
=
false
;
}
}
if
(
valid
==
true
)
{
Toast
.
makeText
(
getApplicationContext
(),
test
,
Toast
.
LENGTH_LONG
).
show
();
Intent
order
=
new
Intent
(
this
,
orderDetails
.
class
);
startActivity
(
order
);
}
else
if
(
valid
==
false
)
{
Toast
.
makeText
(
getApplicationContext
(),
"Please enter a valid car"
,
Toast
.
LENGTH_LONG
).
show
();
}
}
Toast
.
makeText
(
getApplicationContext
(),
test
,
Toast
.
LENGTH_LONG
).
show
();
Intent
order
=
new
Intent
(
this
,
orderDetails
.
class
);
startActivity
(
order
);
}
}
...
...
app/src/main/java/com/example/assignment/orderDetails.java
View file @
7f3cc3eb
...
@@ -2,6 +2,7 @@ package com.example.assignment;
...
@@ -2,6 +2,7 @@ package com.example.assignment;
import
androidx.appcompat.app.AppCompatActivity
;
import
androidx.appcompat.app.AppCompatActivity
;
import
android.content.Intent
;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.view.View
;
import
android.view.View
;
import
android.widget.EditText
;
import
android.widget.EditText
;
...
@@ -129,6 +130,8 @@ if (!“”.equals(temp)){
...
@@ -129,6 +130,8 @@ if (!“”.equals(temp)){
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
);
startActivity
(
list
);
}
}
...
...
app/src/main/java/com/example/assignment/returnCar.java
0 → 100644
View file @
7f3cc3eb
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.Toast
;
public
class
returnCar
extends
AppCompatActivity
{
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_return_car
);
if
(
carPurchase
.
audi
==
false
&&
carPurchase
.
benz
==
false
&&
carPurchase
.
honda
==
false
&&
carPurchase
.
jaguar
==
false
&&
carPurchase
.
toyota
==
false
)
{
Toast
.
makeText
(
getApplicationContext
(),
"There are no cars to be returned at this point."
,
Toast
.
LENGTH_LONG
).
show
();
}
}
public
void
successReturn
()
{
Toast
.
makeText
(
getApplicationContext
(),
"Thank you for returning the car. Sending you back to the car list"
,
Toast
.
LENGTH_LONG
).
show
();
Intent
list
=
new
Intent
(
this
,
Carlist
.
class
);
startActivity
(
list
);
}
public
void
retCar
(
View
v
)
{
EditText
car
=
(
EditText
)
findViewById
(
R
.
id
.
carName
);
String
returnCar
=
car
.
getText
().
toString
();
//(carName.toLowerCase().equals("benz")
if
(
returnCar
.
toLowerCase
().
equals
(
"benz"
))
{
if
(
carPurchase
.
benz
==
false
)
{
Toast
.
makeText
(
getApplicationContext
(),
"This car is currently not in use"
,
Toast
.
LENGTH_LONG
).
show
();
}
else
if
(
carPurchase
.
benz
==
true
)
{
carPurchase
.
benz
=
false
;
successReturn
();
}
}
else
if
(
returnCar
.
toLowerCase
().
equals
(
"audi"
))
{
if
(
carPurchase
.
audi
==
false
)
{
Toast
.
makeText
(
getApplicationContext
(),
"This car is currently not in use"
,
Toast
.
LENGTH_LONG
).
show
();
}
else
if
(
carPurchase
.
audi
==
true
)
{
carPurchase
.
audi
=
false
;
successReturn
();
}
}
else
if
(
returnCar
.
toLowerCase
().
equals
(
"honda"
))
{
if
(
carPurchase
.
honda
==
false
)
{
Toast
.
makeText
(
getApplicationContext
(),
"This car is currently not in use"
,
Toast
.
LENGTH_LONG
).
show
();
}
else
if
(
carPurchase
.
honda
==
true
)
{
carPurchase
.
honda
=
false
;
successReturn
();
}
}
else
if
(
returnCar
.
toLowerCase
().
equals
(
"jaguar"
))
{
if
(
carPurchase
.
jaguar
==
false
)
{
Toast
.
makeText
(
getApplicationContext
(),
"This car is currently not in use"
,
Toast
.
LENGTH_LONG
).
show
();
}
else
if
(
carPurchase
.
jaguar
==
true
)
{
carPurchase
.
jaguar
=
false
;
successReturn
();
}
}
else
if
(
returnCar
.
toLowerCase
().
equals
(
"toyota"
))
{
if
(
carPurchase
.
toyota
==
false
)
{
Toast
.
makeText
(
getApplicationContext
(),
"This car is currently not in use"
,
Toast
.
LENGTH_LONG
).
show
();
}
else
if
(
carPurchase
.
toyota
==
true
)
{
carPurchase
.
toyota
=
false
;
successReturn
();
}
}
else
{
Toast
.
makeText
(
getApplicationContext
(),
"This is not a valid car"
,
Toast
.
LENGTH_LONG
).
show
();
}
}
}
app/src/main/res/layout/activity_carlist.xml
View file @
7f3cc3eb
...
@@ -309,4 +309,16 @@ air conditioning, ABS brakes, 2 people "
...
@@ -309,4 +309,16 @@ air conditioning, ABS brakes, 2 people "
android:text=
"Purchase!"
android:text=
"Purchase!"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/textView17"
/>
app:layout_constraintTop_toBottomOf=
"@+id/textView17"
/>
<Button
android:id=
"@+id/returnCar"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"150dp"
android:layout_marginLeft=
"150dp"
android:layout_marginTop=
"10dp"
android:onClick=
"carReturn"
android:text=
"Return Car"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/button"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
app/src/main/res/layout/activity_return_car.xml
0 → 100644
View file @
7f3cc3eb
<?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=
".returnCar"
>
<TextView
android:id=
"@+id/textView38"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"110dp"
android:layout_marginLeft=
"110dp"
android:layout_marginTop=
"30dp"
android:text=
"Return Car"
android:textColor=
"#000"
android:textSize=
"40sp"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
/>
<TextView
android:id=
"@+id/textView39"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"175dp"
android:layout_marginLeft=
"175dp"
android:layout_marginTop=
"80dp"
android:text=
"Car Name:"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/textView38"
/>
<EditText
android:id=
"@+id/carName"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"100dp"
android:layout_marginLeft=
"100dp"
android:layout_marginTop=
"60dp"
android:ems=
"10"
android:inputType=
"textPersonName"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/textView39"
/>
<Button
android:id=
"@+id/submit"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"160dp"
android:layout_marginLeft=
"160dp"
android:layout_marginTop=
"145dp"
android:onClick=
"retCar"
android:text=
"Submit"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/carName"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
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