first commit

This commit is contained in:
Boris
2024-01-15 20:14:10 +00:00
commit 8c81ee28b7
3106 changed files with 474415 additions and 0 deletions

Binary file not shown.

View File

@@ -0,0 +1,26 @@
#BlueJ class context
comment0.params=
comment0.target=Holiday()
comment0.text=\n\ Default\ constructor\ for\ objects\ of\ class\ Holiday\n
comment1.params=refNumber\ type\ price
comment1.target=Holiday(java.lang.String,\ java.lang.String,\ int)
comment1.text=\n\ Constructor\ for\ objects\ of\ class\ Holiday.\n
comment2.params=
comment2.target=java.lang.String\ getRefNumber()
comment2.text=\n\ Return\ the\ reference\ number\ of\ the\ holiday.\n
comment3.params=
comment3.target=java.lang.String\ getType()
comment3.text=\n\ Return\ the\ type\ of\ the\ holiday.\n
comment4.params=
comment4.target=int\ getPrice()
comment4.text=\n\ Return\ the\ price\ of\ the\ holiday.\n
comment5.params=refNumber
comment5.target=void\ setRefNumber(java.lang.String)
comment5.text=\n\ Set\ the\ reference\ number\ of\ the\ holiday\ to\ a\ new\ value.\n
comment6.params=type
comment6.target=void\ setType(java.lang.String)
comment6.text=\n\ Set\ the\ type\ of\ the\ holiday\ to\ a\ new\ value.\n
comment7.params=price
comment7.target=void\ setPrice(int)
comment7.text=\n\ Set\ the\ price\ of\ the\ holiday\ to\ a\ new\ value.\n
numComments=8

View File

@@ -0,0 +1,87 @@
/**
* Write a description of class Holiday here.
*
* @George Wilkinson
* @3/11/23
*/
public class Holiday
{
// Create a String variable to hold the reference number.
private String refNumber;
// Create a String variable to hold the type of holiday.
private String type;
// Create an integer variable to hold the price in pounds of the holiday.
private int price;
/**
* Default constructor for objects of class Holiday
*/
public Holiday()
{
// initialise instance variables
refNumber = "W001";
type = "beach";
price = 300;
}
/**
* Constructor for objects of class Holiday.
*/
public Holiday( String refNumber, String type, int price )
{
this.refNumber = refNumber;
this.type = type;
this.price = price;
}
/**
* Return the reference number of the holiday.
*/
public String getRefNumber()
{
return refNumber;
}
/**
* Return the type of the holiday.
*/
public String getType()
{
return type;
}
/**
* Return the price of the holiday.
*/
public int getPrice()
{
return price;
}
/**
* Set the reference number of the holiday to a new value.
*/
public void setRefNumber( String refNumber )
{
this.refNumber = refNumber;
}
/**
* Set the type of the holiday to a new value.
*/
public void setType( String type )
{
this.type = type;
}
/**
* Set the price of the holiday to a new value.
*/
public void setPrice( int price )
{
this.price = price;
}
}

Binary file not shown.

View File

@@ -0,0 +1,44 @@
#BlueJ class context
comment0.params=
comment0.target=Member()
comment0.text=\n\ Default\ Constructor\ for\ objects\ of\ Class\ Member.\n
comment1.params=email\ membershipNumber
comment1.target=Member(java.lang.String,\ int)
comment1.text=\n\ Constructor\ for\ objects\ of\ class\ Member\n
comment10.params=website
comment10.target=void\ setWebsite(Website)
comment10.text=\n\ Sets\ the\ object\ pointed\ to\ by\ the\ member.\n
comment11.params=holiday
comment11.target=void\ setHoliday(Holiday)
comment11.text=\n\ Sets\ the\ object\ pointed\ to\ by\ the\ member.\n\ Currently\ used\ to\ clear\ the\ member's\ checkout\ after\ paying.\n
comment12.params=holiday
comment12.target=void\ selectHoliday(Holiday)
comment12.text=\n\ Allows\ member\ to\ select\ a\ holiday\ object,\ provided\ they\ are\ logged\ into\ a\ website.\n
comment13.params=
comment13.target=void\ payForHoliday()
comment13.text=\n\ Allows\ member\ to\ pay\ for\ a\ holiday,\ provided\ they\ are\ logged\ in,\ passing\ itself\ to\ website.checkout().\n
comment2.params=
comment2.target=java.lang.String\ getEmail()
comment2.text=\n\ Returns\ the\ value\ of\ @email.\n
comment3.params=
comment3.target=int\ getMembershipNumber()
comment3.text=\n\ Returns\ the\ value\ of\ @membershipNumber.\n
comment4.params=
comment4.target=boolean\ getLoggedInStatus()
comment4.text=\n\ Returns\ the\ value\ of\ @loggedInStatus.\n
comment5.params=
comment5.target=Holiday\ getHoliday()
comment5.text=\n\ Returns\ the\ current\ selected\ holiday\ object.\n
comment6.params=
comment6.target=Website\ getWebsite()
comment6.text=\n\ Returns\ the\ current\ logged\ in\ website\ object.\n
comment7.params=email
comment7.target=void\ setEmail(java.lang.String)
comment7.text=\n\ Replaces\ the\ value\ of\ @email\ with\ a\ new\ value.\n
comment8.params=membershipNumber
comment8.target=void\ setMembershipNumber(int)
comment8.text=\n\ Replaces\ the\ value\ of\ @membershipNumber\ with\ new\ value.\n
comment9.params=loggedInStatus
comment9.target=void\ setLoggedInStatus(boolean)
comment9.text=\n\ Replaces\ the\ value\ of\ @loggedInStatus\ with\ new\ value.\n
numComments=14

View File

@@ -0,0 +1,159 @@
/**
* Represents a user of a holiday website.
*
* @George Wilkinson
* @13/11/23
*/
public class Member
{
// Creates a String for variable @email.
private String email;
// Creates an integer for variable @membershipNumber.
private int membershipNumber;
// Creates a boolean for variable @loggedInStatus.
private boolean loggedInStatus;
//Creates a new pointer to a Holiday object.
private Holiday holiday;
// Creates a new pointer to a Website object.
private Website website;
/**
* Default Constructor for objects of Class Member.
*/
public Member()
{
email = "john.doe@topstravel.co.uk";
membershipNumber = 1;
loggedInStatus = false;
}
/**
* Constructor for objects of class Member
*/
public Member( String email, int membershipNumber )
{
// initialise instance variables
this.email = email;
this.membershipNumber = membershipNumber;
loggedInStatus = false;
}
/**
* Returns the value of @email.
*/
public String getEmail()
{
return email;
}
/**
* Returns the value of @membershipNumber.
*/
public int getMembershipNumber()
{
return membershipNumber;
}
/**
* Returns the value of @loggedInStatus.
*/
public boolean getLoggedInStatus()
{
return loggedInStatus;
}
/**
* Returns the current selected holiday object.
*/
public Holiday getHoliday()
{
return holiday;
}
/**
* Returns the current logged in website object.
*/
public Website getWebsite()
{
return website;
}
/**
* Replaces the value of @email with a new value.
*/
public void setEmail( String email )
{
this.email = email;
}
/**
* Replaces the value of @membershipNumber with new value.
*/
public void setMembershipNumber( int membershipNumber )
{
this.membershipNumber = membershipNumber;
}
/**
* Replaces the value of @loggedInStatus with new value.
*/
public void setLoggedInStatus( boolean loggedInStatus )
{
this.loggedInStatus = loggedInStatus;
}
/**
* Sets the object pointed to by the member.
*/
public void setWebsite( Website website )
{
this.website = website;
}
/**
* Sets the object pointed to by the member.
* Currently used to clear the member's checkout after paying.
*/
public void setHoliday( Holiday holiday )
{
this.holiday = holiday;
}
/**
* Allows member to select a holiday object, provided they are logged into a website.
*/
public void selectHoliday( Holiday holiday )
{
if( loggedInStatus )
{
this.holiday = holiday;
System.out.println( "member ID: " + membershipNumber );
System.out.println( "holiday ref number: " + holiday.getRefNumber() );
System.out.println( "holiday type: " + holiday.getType() );
System.out.println( "holiday price: £" + holiday.getPrice() );
}
else {
System.out.println( "You are not logged in" );
}
}
/**
* Allows member to pay for a holiday, provided they are logged in, passing itself to website.checkout().
*/
public void payForHoliday()
{
if( loggedInStatus )
{
//Pass current member to the checkout method of website
website.checkout( this );
}
else {
System.out.println( "You are not logged in" );
}
}
}

View File

@@ -0,0 +1,12 @@
------------------------------------------------------------------------
This is the project README file. Here, you should describe your project.
Tell the reader (someone who does not know anything about this project)
all he/she needs to know. The comments should usually include at least:
------------------------------------------------------------------------
PROJECT TITLE:
PURPOSE OF PROJECT:
VERSION or DATE:
HOW TO START THIS PROJECT:
AUTHORS:
USER INSTRUCTIONS:

Binary file not shown.

View File

@@ -0,0 +1,38 @@
#BlueJ class context
comment0.params=
comment0.target=Website()
comment0.text=\n\ Default\ constructor\ for\ objects\ of\ class\ Website\n
comment1.params=websiteName
comment1.target=Website(java.lang.String)
comment1.text=\n\ Constructor\ for\ objects\ of\ class\ Website\n
comment10.params=member
comment10.target=void\ checkout(Member)
comment10.text=\n\ Provides\ a\ checkout\ to\ the\ member\ buying\ a\ holiday.\ This\ will\ also\ apply\ the\ hit\ discount,\ \n\ and\ amend\ the\ purchase\ to\ the\ sales\ total\ field\ variable\n
comment11.params=
comment11.target=boolean\ checkHitDiscount()
comment11.text=\n\ Returns\ true\ or\ false,\ depending\ on\ the\ current\ state\ of\ hit\ count.\n\ Every\ 10th\ member,\ result\ is\ true\n
comment2.params=
comment2.target=java.lang.String\ getWebsiteName()
comment2.text=\n\ Return\ website's\ name\n
comment3.params=
comment3.target=int\ getHits()
comment3.text=\n\ Return\ hit\ count\ of\ website\n
comment4.params=
comment4.target=double\ getSalesTotal()
comment4.text=\n\ Return\ total\ sales\ of\ holidays\ purchased\ through\ the\ website.\n
comment5.params=websiteName
comment5.target=void\ setWebsiteName(java.lang.String)
comment5.text=\n\ Set\ the\ website's\ name\ to\ a\ new\ value.\n
comment6.params=hits
comment6.target=void\ setHits(int)
comment6.text=\n\ Set\ the\ website's\ hit\ count\ to\ a\ new\ value.\n
comment7.params=salesTotal
comment7.target=void\ setSalesTotal(double)
comment7.text=\n\ Set\ the\ total\ sales\ of\ the\ website\ to\ a\ new\ value.\n
comment8.params=member
comment8.target=void\ memberLogin(Member)
comment8.text=\n\ Allows\ the\ website\ to\ be\ logged\ into,\ taking\ a\ Member\ object\ as\ a\ parameter.\n
comment9.params=member
comment9.target=void\ memberLogout(Member)
comment9.text=\n\ Allows\ the\ current\ user\ of\ the\ website\ to\ be\ logged\ out,\ as\ long\ as\ there\ is\ a\ user\ logged\ in.\n\ The\ if\ statement\ here\ allows\ us\ to\ avoid\ a\ null\ reference\ error.\n
numComments=12

View File

@@ -0,0 +1,168 @@
/**
* Represents a holiday website, where members can purchase holidays.
*
* @George Wilkinson
* @13/11/23
*/
public class Website
{
// Creates a String variable to hold the name of the website.
private String websiteName;
// Creates an integer variable to hold the amount of logins (hits).
private int hits;
// Creates an integer variable to hold the total sales in pounds.
private double salesTotal;
/**
* Default constructor for objects of class Website
*/
public Website()
{
websiteName = "Club 18";
hits = 1257;
salesTotal = 10592.0;
}
/**
* Constructor for objects of class Website
*/
public Website( String websiteName )
{
this.websiteName = websiteName;
this.hits = 0;
this.salesTotal = 0.0;
}
/**
* Return website's name
*/
public String getWebsiteName()
{
return websiteName;
}
/**
* Return hit count of website
*/
public int getHits()
{
return hits;
}
/**
* Return total sales of holidays purchased through the website.
*/
public double getSalesTotal()
{
return salesTotal;
}
/**
* Set the website's name to a new value.
*/
public void setWebsiteName( String websiteName )
{
this.websiteName = websiteName;
}
/**
* Set the website's hit count to a new value.
*/
public void setHits( int hits )
{
this.hits = hits;
}
/**
* Set the total sales of the website to a new value.
*/
public void setSalesTotal( double salesTotal )
{
this.salesTotal = salesTotal;
}
/**
* Allows the website to be logged into, taking a Member object as a parameter.
*/
public void memberLogin( Member member )
{
if( !member.getLoggedInStatus() )
{
//User status to logged in
member.setLoggedInStatus( true );
//Assign to a website
member.setWebsite( this );
System.out.println( websiteName + " welcome member " + member.getMembershipNumber() + ", you are now logged in" );
//Increment hits
hits++;
}
else {
System.out.println( "Current user is still logged in, please try again later." );
}
}
/**
* Allows the current user of the website to be logged out, as long as there is a user logged in.
* The if statement here allows us to avoid a null reference error.
*/
public void memberLogout( Member member )
{
if( member.getLoggedInStatus() )
{
//User status logged out
member.setLoggedInStatus( false );
//No longer registered to a website
member.setWebsite( null );
System.out.println( websiteName + ": goodbye member " + member.getMembershipNumber() + ", you are now logged out" );
}
else
{
System.out.println( "User not logged in" );
}
}
/**
* Provides a checkout to the member buying a holiday. This will also apply the hit discount,
* and amend the purchase to the sales total field variable
*/
public void checkout( Member member )
{
if( member.getHoliday() != null ) {
//Stores the integer price of holiday as a double so it can be discounted.
//This couldve been avoided by repeating redundant code but this is cleaner.
double holidayPrice = member.getHoliday().getPrice();
if( checkHitDiscount() == true )
{
//Discounts price, hence why holidayPrice must be a double
holidayPrice = holidayPrice * 0.9;
System.out.println( "Congratulations! You are the 10th user to book a holiday, you will recieve a 10% discount on this holiday." );
}
//Add holiday price to running total
salesTotal += holidayPrice;
System.out.println("Your purchase totaling £" + holidayPrice + " was sucessful, user " + member.getMembershipNumber() + ", thank you for using Tops Travel.");
member.setHoliday( null );
}
else
{
System.out.println( "You have not selected a holiday!" );
}
}
/**
* Returns true or false, depending on the current state of hit count.
* Every 10th member, result is true
*/
public boolean checkHitDiscount()
{
//hits mod 10, when hits is multiple of 10, return true.
return ( hits % 10 ) == 0;
}
}

View File

@@ -0,0 +1,60 @@
#BlueJ package file
dependency1.from=Website
dependency1.to=Member
dependency1.type=UsesDependency
dependency2.from=Member
dependency2.to=Holiday
dependency2.type=UsesDependency
dependency3.from=Member
dependency3.to=Website
dependency3.type=UsesDependency
objectbench.height=305
objectbench.width=825
package.editor.height=645
package.editor.width=699
package.editor.x=0
package.editor.y=31
package.numDependencies=3
package.numTargets=3
package.showExtends=true
package.showUses=true
project.charset=UTF-8
target1.editor.height=700
target1.editor.width=900
target1.editor.x=40
target1.editor.y=51
target1.height=50
target1.name=Holiday
target1.naviview.expanded=true
target1.showInterface=false
target1.type=ClassTarget
target1.typeParameters=
target1.width=80
target1.x=280
target1.y=160
target2.editor.height=1049
target2.editor.width=1041
target2.editor.x=0
target2.editor.y=31
target2.height=50
target2.name=Website
target2.naviview.expanded=true
target2.showInterface=false
target2.type=ClassTarget
target2.typeParameters=
target2.width=90
target2.x=120
target2.y=60
target3.editor.height=700
target3.editor.width=900
target3.editor.x=0
target3.editor.y=31
target3.height=50
target3.name=Member
target3.naviview.expanded=true
target3.showInterface=false
target3.type=ClassTarget
target3.typeParameters=
target3.width=90
target3.x=200
target3.y=110