Initial Commit P2 Part 1
This commit is contained in:
BIN
Semester 2/Programming 2/Project/Part 1/Library.class
Normal file
BIN
Semester 2/Programming 2/Project/Part 1/Library.class
Normal file
Binary file not shown.
9
Semester 2/Programming 2/Project/Part 1/Library.ctxt
Normal file
9
Semester 2/Programming 2/Project/Part 1/Library.ctxt
Normal file
@@ -0,0 +1,9 @@
|
||||
#BlueJ class context
|
||||
comment0.params=
|
||||
comment0.target=Library()
|
||||
comment0.text=\n\ Constructor\ for\ objects\ of\ class\ Library\n
|
||||
comment1.params=item
|
||||
comment1.target=void\ storeItem(LibraryItem)
|
||||
comment2.params=
|
||||
comment2.target=void\ printAllItems()
|
||||
numComments=3
|
36
Semester 2/Programming 2/Project/Part 1/Library.java
Normal file
36
Semester 2/Programming 2/Project/Part 1/Library.java
Normal file
@@ -0,0 +1,36 @@
|
||||
|
||||
/**
|
||||
* Write a description of class Library here.
|
||||
*
|
||||
* @author (your name)
|
||||
* @version (a version number or a date)
|
||||
*/
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Library
|
||||
{
|
||||
private ArrayList<LibraryItem> itemList;
|
||||
|
||||
/**
|
||||
* Constructor for objects of class Library
|
||||
*/
|
||||
public Library()
|
||||
{
|
||||
itemList = new ArrayList<LibraryItem>();
|
||||
}
|
||||
|
||||
public void storeItem( LibraryItem item )
|
||||
{
|
||||
itemList.add( item );
|
||||
}
|
||||
|
||||
public void printAllItems()
|
||||
{
|
||||
for( LibraryItem item : itemList )
|
||||
{
|
||||
item.printDetails();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
BIN
Semester 2/Programming 2/Project/Part 1/LibraryItem.class
Normal file
BIN
Semester 2/Programming 2/Project/Part 1/LibraryItem.class
Normal file
Binary file not shown.
30
Semester 2/Programming 2/Project/Part 1/LibraryItem.ctxt
Normal file
30
Semester 2/Programming 2/Project/Part 1/LibraryItem.ctxt
Normal file
@@ -0,0 +1,30 @@
|
||||
#BlueJ class context
|
||||
comment0.params=title\ itemCode\ cost\ timesBorrowed\ onLoan
|
||||
comment0.target=LibraryItem(java.lang.String,\ java.lang.String,\ int,\ int,\ boolean)
|
||||
comment0.text=\n\ Constructor\ for\ objects\ of\ class\ LibraryItem\n
|
||||
comment1.params=
|
||||
comment1.target=java.lang.String\ getTitle()
|
||||
comment1.text=\n\ Field\ Accessor\ Start\n
|
||||
comment10.params=onLoan
|
||||
comment10.target=void\ setOnLoan(boolean)
|
||||
comment11.params=
|
||||
comment11.target=void\ printDetails()
|
||||
comment11.text=\n\ Field\ Mutator\ End\n
|
||||
comment2.params=
|
||||
comment2.target=java.lang.String\ getItemCode()
|
||||
comment3.params=
|
||||
comment3.target=int\ getCost()
|
||||
comment4.params=
|
||||
comment4.target=int\ getTimesBorrowed()
|
||||
comment5.params=
|
||||
comment5.target=boolean\ getOnLoan()
|
||||
comment6.params=title
|
||||
comment6.target=void\ setTitle(java.lang.String)
|
||||
comment6.text=\n\ Field\ Accessor\ End\n\ \n\ Field\ Mutator\ Start\n
|
||||
comment7.params=itemCode
|
||||
comment7.target=void\ setItemCode(java.lang.String)
|
||||
comment8.params=cost
|
||||
comment8.target=void\ setCost(int)
|
||||
comment9.params=timesBorrowed
|
||||
comment9.target=void\ setTimesBorrowed(int)
|
||||
numComments=12
|
103
Semester 2/Programming 2/Project/Part 1/LibraryItem.java
Normal file
103
Semester 2/Programming 2/Project/Part 1/LibraryItem.java
Normal file
@@ -0,0 +1,103 @@
|
||||
|
||||
/**
|
||||
* Write a description of class LibraryItem here.
|
||||
*
|
||||
* @author (your name)
|
||||
* @version (a version number or a date)
|
||||
*/
|
||||
public class LibraryItem
|
||||
{
|
||||
// instance variables - replace the example below with your own
|
||||
private String title;
|
||||
private String itemCode;
|
||||
private int cost;
|
||||
private int timesBorrowed;
|
||||
private boolean onLoan;
|
||||
|
||||
/**
|
||||
* Constructor for objects of class LibraryItem
|
||||
*/
|
||||
public LibraryItem( String title, String itemCode, int cost, int timesBorrowed, boolean onLoan)
|
||||
{
|
||||
this.title = title;
|
||||
this.itemCode = itemCode;
|
||||
this.cost = cost;
|
||||
this.timesBorrowed = timesBorrowed;
|
||||
this.onLoan = onLoan;
|
||||
}
|
||||
|
||||
/*
|
||||
* Field Accessor Start
|
||||
*/
|
||||
public String getTitle()
|
||||
{
|
||||
return title;
|
||||
}
|
||||
|
||||
public String getItemCode()
|
||||
{
|
||||
return itemCode;
|
||||
}
|
||||
|
||||
public int getCost()
|
||||
{
|
||||
return cost;
|
||||
}
|
||||
|
||||
public int getTimesBorrowed()
|
||||
{
|
||||
return timesBorrowed;
|
||||
}
|
||||
|
||||
public boolean getOnLoan()
|
||||
{
|
||||
return onLoan;
|
||||
}
|
||||
|
||||
/*
|
||||
* Field Accessor End
|
||||
*
|
||||
* Field Mutator Start
|
||||
*/
|
||||
|
||||
public void setTitle( String title )
|
||||
{
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public void setItemCode( String itemCode )
|
||||
{
|
||||
this.itemCode = itemCode;
|
||||
}
|
||||
|
||||
public void setCost( int cost )
|
||||
{
|
||||
this.cost = cost;
|
||||
}
|
||||
|
||||
public void setTimesBorrowed( int timesBorrowed )
|
||||
{
|
||||
this.timesBorrowed = timesBorrowed;
|
||||
}
|
||||
|
||||
public void setOnLoan( boolean onLoan )
|
||||
{
|
||||
this.onLoan = onLoan;
|
||||
}
|
||||
|
||||
/*
|
||||
* Field Mutator End
|
||||
*/
|
||||
|
||||
// Output to console the details of the fields in a human-readable format.
|
||||
public void printDetails()
|
||||
{
|
||||
System.out.println( title + " with an item code " + itemCode + " has been borrowed " + timesBorrowed + " times.");
|
||||
if( onLoan )
|
||||
System.out.println( "This item is at present on loan and when new cost " + cost + " pence." );
|
||||
else
|
||||
System.out.println( "This item is at present not on loan and when new cost " + cost + " pence." );
|
||||
}
|
||||
|
||||
|
||||
}
|
12
Semester 2/Programming 2/Project/Part 1/README.TXT
Normal file
12
Semester 2/Programming 2/Project/Part 1/README.TXT
Normal 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:
|
3
Semester 2/Programming 2/Project/Part 1/package.bluej
Normal file
3
Semester 2/Programming 2/Project/Part 1/package.bluej
Normal file
@@ -0,0 +1,3 @@
|
||||
#BlueJ package file
|
||||
#Fri Feb 02 12:26:48 GMT 2024
|
||||
project.charset=UTF-8
|
Reference in New Issue
Block a user