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,67 @@
#BlueJ class context
comment0.params=
comment0.target=void\ test()
comment1.params=type\ homeAddress\ initPrice\ energyRating\ taxBand\ garage
comment1.target=House(java.lang.String,\ java.lang.String,\ int,\ int,\ char,\ boolean)
comment1.text=\n\ Constructor\ for\ objects\ of\ class\ House\n
comment10.params=
comment10.target=java.lang.String\ getOwner()
comment10.text=\n\ Returns\ the\ value\ of\ @owner\n
comment11.params=
comment11.target=int\ getNumberOfOwners()
comment11.text=\n\ Returns\ the\ value\ of\ @numberOfOwners\n
comment12.params=type
comment12.target=void\ setType(java.lang.String)
comment12.text=\n\ Set\ @typeOfHouse\ to\ a\ user-input\ value\n
comment13.params=newAddress
comment13.target=void\ setAddress(java.lang.String)
comment13.text=\n\ Set\ @address\ to\ a\ user-input\ value\n
comment14.params=newBand
comment14.target=void\ setCouncilTaxBand(char)
comment14.text=\n\ Set\ @councilTaxBand\ to\ a\ user-input\ value\n
comment15.params=garage
comment15.target=void\ setGarage(boolean)
comment15.text=\n\ Set\ @hasGarage\ to\ a\ user-input\ value\n
comment16.params=newOwner
comment16.target=void\ setOwner(java.lang.String)
comment16.text=\n\ Set\ @owner\ to\ a\ user-input\ value\n
comment17.params=newPurchasePrice
comment17.target=void\ setPurchasePrice(int)
comment17.text=\n\ Set\ @purchasePrice\ to\ a\ user-input\ value\n
comment18.params=newNumberOfOwners
comment18.target=void\ setNumberOfOwners(int)
comment18.text=\n\ Set\ @numberOfOwners\ to\ a\ user-input\ value\n
comment19.params=
comment19.target=void\ printDetails()
comment19.text=\n\ Print\ all\ fields\ of\ object\ for\ the\ user.\n
comment2.params=newHomeEnergyRating
comment2.target=void\ goingGreener(int)
comment2.text=\n\ Simulates\ changing\ home\ efficiency\ value.\n\ Takes\ @homeEnergyRating\ and\ replaces\ with\ a\ user\ input\ value\ @newHomeEnergyRating,\ then\n\ prints\ a\ confirmation\ message\ to\ the\ output\ log.\n
comment20.params=
comment20.target=void\ checkHomeEnergyRating()
comment20.text=\n\ Print\ to\ log\ when\ @homeEnergyRating\ is\ above\ or\ below\ a\ threshold\ of\ 3.\n
comment21.params=newOwner\ newPurchasePrice
comment21.target=void\ sell(java.lang.String,\ int)
comment21.text=\n\ Simulates\ selling\ the\ house\ by\ calling\ the\ setOwner()\ and\ setPurchasePrice()\ methods.\n
comment3.params=
comment3.target=java.lang.String\ getType()
comment3.text=\n\ Returns\ the\ value\ of\ @typeOfHouse\ to\ the\ user.\n
comment4.params=
comment4.target=java.lang.String\ getAddress()
comment4.text=\n\ Returns\ the\ value\ of\ @address\n
comment5.params=
comment5.target=int\ getInitialPurchasePrice()
comment5.text=\n\ Returns\ the\ value\ of\ @initalPurchasePrice\n
comment6.params=
comment6.target=int\ getEnergyRating()
comment6.text=\n\ Returns\ the\ value\ of\ @homeEnergyRating\n
comment7.params=
comment7.target=char\ getTaxBand()
comment7.text=\n\ Returns\ the\ value\ of\ @councilTaxBand\n
comment8.params=
comment8.target=boolean\ getGarage()
comment8.text=\n\ Returns\ the\ value\ of\ @hasGarage\n
comment9.params=
comment9.target=int\ getPurchasePrice()
comment9.text=\n\ Returns\ the\ value\ of\ @purchasePrice\n
numComments=22

View File

@@ -0,0 +1,237 @@
/**
* This class is an imitation of a house for sale in a real estate business. It allows for the buying, selling and modification of the house.
*
* @author George Wilkinson
* @version 6/10/23
*/
public class House
{
// instance variables
private String typeOfHouse;
private String address;
private int initialPurchasePrice;
private int purchasePrice;
private int homeEnergyRating;
private char councilTaxBand;
private String owner;
private int numberOfOwners;
private boolean hasGarage;
/**
* Constructor for objects of class House
*/
public House( String type, String homeAddress, int initPrice, int energyRating, char taxBand, boolean garage)
{
// initialise house attriutes
typeOfHouse = type;
address = homeAddress;
initialPurchasePrice = initPrice;
homeEnergyRating = energyRating;
councilTaxBand = taxBand;
hasGarage = garage;
purchasePrice = 0;
owner = "None";
numberOfOwners = 0;
checkHomeEnergyRating();
}
/**
* Simulates changing home efficiency value.
* Takes @homeEnergyRating and replaces with a user input value @newHomeEnergyRating, then
* prints a confirmation message to the output log.
*/
public void goingGreener( int newHomeEnergyRating )
{
homeEnergyRating = newHomeEnergyRating; //Update homeEnergyRating variable's value
}
/**
* Returns the value of @typeOfHouse to the user.
*/
public String getType()
{
return typeOfHouse;
}
/**
* Returns the value of @address
*/
public String getAddress()
{
return address;
}
/**
* Returns the value of @initalPurchasePrice
*/
public int getInitialPurchasePrice()
{
return initialPurchasePrice;
}
/**
* Returns the value of @homeEnergyRating
*/
public int getEnergyRating()
{
return homeEnergyRating;
}
/**
* Returns the value of @councilTaxBand
*/
public char getTaxBand()
{
return councilTaxBand;
}
/**
* Returns the value of @hasGarage
*/
public boolean getGarage()
{
return hasGarage;
}
/**
* Returns the value of @purchasePrice
*/
public int getPurchasePrice()
{
return purchasePrice;
}
/**
* Returns the value of @owner
*/
public String getOwner()
{
return owner;
}
/**
* Returns the value of @numberOfOwners
*/
public int getNumberOfOwners()
{
return numberOfOwners;
}
/**
* Set @typeOfHouse to a user-input value
*/
public void setType( String type )
{
typeOfHouse = type; //Update the type variable's value
System.out.println( "Type of this house is now: " + typeOfHouse );
}
/**
* Set @address to a user-input value
*/
public void setAddress( String newAddress )
{
address = newAddress; //Update the address variable's value
System.out.println( "Address of this house is now: " + address );
}
/**
* Set @councilTaxBand to a user-input value
*/
public void setCouncilTaxBand( char newBand )
{
councilTaxBand = newBand; //Update the Tax Band variable's value
System.out.println( "Council Tax Band of this house is now: " + councilTaxBand );
}
/**
* Set @hasGarage to a user-input value
*/
public void setGarage( boolean garage )
{
hasGarage = garage; //Update the garage variable's value
System.out.println( "Garage state of this house is: " + hasGarage );
}
/**
* Set @owner to a user-input value
*/
public void setOwner( String newOwner )
{
owner = newOwner; //Update the owner variable's value
System.out.println( "Owner of this house is now: " + owner );
}
/**
* Set @purchasePrice to a user-input value
*/
public void setPurchasePrice( int newPurchasePrice )
{
purchasePrice = newPurchasePrice; //Update the purchasePrice variable's value
System.out.println( "House has been purchased for: £" + purchasePrice );
}
/**
* Set @numberOfOwners to a user-input value
*/
public void setNumberOfOwners( int newNumberOfOwners )
{
numberOfOwners = newNumberOfOwners;
System.out.println( "Number of Owners of this house is now: " + numberOfOwners );
}
/**
* Print all fields of object for the user.
*/
public void printDetails()
{
System.out.println( "House type: " + typeOfHouse );
System.out.println( "Address: " + address );
System.out.println( "Original purchase price in pounds: " + initialPurchasePrice );
System.out.println( "Current price in pounds: " + purchasePrice );
System.out.println( "Home energy rating: " + homeEnergyRating );
System.out.println( "Council Tax Band: " + councilTaxBand );
System.out.println( "Number of owners to date: " + numberOfOwners );
System.out.println( "Current owner: " + owner );
}
/**
* Print to log when @homeEnergyRating is above or below a threshold of 3.
*/
public void checkHomeEnergyRating()
{
if( homeEnergyRating < 3 )
{
System.out.println( "Be aware that extra green taxes may be imposed on this house" );
}
else
{
System.out.println( "This house will not be subject to extra taxes" );
}
}
/**
* Simulates selling the house by calling the setOwner() and setPurchasePrice() methods.
*/
public void sell( String newOwner, int newPurchasePrice )
{
setOwner( newOwner ); //Call the setOwner method to set the purchaser's name
setPurchasePrice( newPurchasePrice ); //Call the setPurchasePrice method to set the buy price of the house after it is sold.
setNumberOfOwners( numberOfOwners + 1 ); //Call the setNumberOfOwners mutator to increment the owner count after selling.
}
}

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:

View File

@@ -0,0 +1,32 @@
Class documentation
<---- javadoc command: ---->
/usr/lib/jvm/java-8-openjdk-amd64/bin/javadoc
-author
-version
-nodeprecated
-package
-noindex
-notree
-nohelp
-nonavbar
-source
1.8
-classpath
/usr/share/bluej/bluejcore.jar:/usr/share/bluej/junit-4.8.2.jar:/usr/share/bluej/userlib/pi4j-gpio-extension.jar:/usr/share/bluej/userlib/pi4j-device.jar:/usr/share/bluej/userlib/pi4j-core.jar:/usr/share/bluej/userlib/pi4j-service.jar:/home/boris/OneDrive/Computer Science Year 1/Programming 1/Week 3/Homework 1
-d
/home/boris/OneDrive/Computer Science Year 1/Programming 1/Week 3/Homework 1/doc
-encoding
UTF-8
-charset
UTF-8
-docletpath
/usr/share/bluej/bjdoclet.jar
-doclet
bluej.doclet.doclets.formats.html.HtmlDoclet
/home/boris/OneDrive/Computer Science Year 1/Programming 1/Week 3/Homework 1/House.java
<---- end of javadoc command ---->
Loading source file /home/boris/OneDrive/Computer Science Year 1/Programming 1/Week 3/Homework 1/House.java...
/home/boris/OneDrive/Computer Science Year 1/Programming 1/Week 3/Homework 1/House.java:40: error: illegal start of expression
if ( councilTaxBand != 'A' || councilTaxBand != 'B' || councilTaxBand != 'C' || councilTaxBand != 'D' || councilTaxBand != 'E' || )
^
1 error

View File

@@ -0,0 +1,25 @@
#BlueJ package file
objectbench.height=76
objectbench.width=940
package.editor.height=874
package.editor.width=814
package.editor.x=0
package.editor.y=31
package.numDependencies=0
package.numTargets=1
package.showExtends=true
package.showUses=true
project.charset=UTF-8
target1.editor.height=1049
target1.editor.width=960
target1.editor.x=0
target1.editor.y=31
target1.height=50
target1.name=House
target1.naviview.expanded=true
target1.showInterface=false
target1.type=ClassTarget
target1.typeParameters=
target1.width=80
target1.x=210
target1.y=210

View File

@@ -0,0 +1,51 @@
## Lecture 1 (11:00)
## Lecture 2 (14:00)
### Modifiers
```java
private
public
```
- These are two examples of modifiers in java. Will cover more in chapter 3
### Mutator Vs Accessor Methods
```java
public void changeColour( int newColour )
{
colour = newColour;
draw();
}
```
- An example of a **mutator** method. Since the method **mutates** an integer, and does not return a value.
```java
public int getPrice()
{
return price;
}
```
- This would be an example of an **accessor** method. Since this accesses a value and outputs to a location.
### Formal Vs Actual Parameter
```java
public void changeSize( int newDiameter )
```
- newDiameter is the **formal** parameter
- The value of newDiameter is the **actual** parameter
### Good Practices
- Vertically align braces, since it allows for better error checking
### Extra Stuff
- Homework Wednesday
- Name everything exactly, marking is automated