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

View File

@@ -0,0 +1,9 @@
#BlueJ class context
comment0.target=Database()
comment0.text=\nCreate\ a\ new,\ empty\ person\ database.\n\n
comment1.params=p
comment1.target=void\ addPerson(Person)
comment1.text=\nAdd\ a\ person\ to\ the\ database.\n\n
comment2.target=void\ listAll()
comment2.text=\nList\ all\ the\ persons\ currently\ in\ the\ database\ on\ standard\ out.\n\n
numComments=3

View File

@@ -0,0 +1,43 @@
import java.util.ArrayList;
import java.util.Iterator;
/**
* A very simple database of people in a university. This class simply stores
* persons and, at request, lists them on standard output.
*
* Written as a first demo program for BlueJ.
*
* @author Michael Kolling
* @version 1.1, March 2002
*/
public class Database {
private ArrayList persons;
/**
* Create a new, empty person database.
*/
public Database()
{
persons = new ArrayList();
}
/**
* Add a person to the database.
*/
public void addPerson(Person p)
{
persons.add(p);
}
/**
* List all the persons currently in the database on standard out.
*/
public void listAll ()
{
for (Iterator i = persons.iterator(); i.hasNext();) {
System.out.println(i.next());
}
}
}

View File

@@ -0,0 +1,17 @@
#BlueJ class context
comment0.params=name\ yearOfBirth
comment0.target=Person(String,\ int)
comment0.text=\nCreate\ a\ person\ with\ given\ name\ and\ age.\n\n
comment1.params=newName
comment1.target=void\ setName(String)
comment1.text=\nSet\ a\ new\ name\ for\ this\ person.\n\n
comment2.target=String\ getName()
comment2.text=\nReturn\ the\ name\ of\ this\ person.\n\n
comment3.params=newYearOofBirth
comment3.target=void\ setYearOfBirth(int)
comment3.text=\nSet\ a\ new\ birth\ year\ for\ this\ person.\n\n
comment4.target=int\ getYearOfBirth()
comment4.text=\nReturn\ the\ birth\ year\ of\ this\ person.\n\n
comment5.target=String\ toString()
comment5.text=\nReturn\ a\ string\ representation\ of\ this\ object.\n\n
numComments=6

View File

@@ -0,0 +1,63 @@
/**
* A person class for a simple BlueJ demo program. Person is used as
* an abstract superclass of more specific person classes.
*
* @author Michael Kolling
* @version 1.0, January 1999
*/
abstract class Person
{
private String name;
private int yearOfBirth;
/**
* Create a person with given name and age.
*/
Person(String name, int yearOfBirth)
{
this.name = name;
this.yearOfBirth = yearOfBirth;
}
/**
* Set a new name for this person.
*/
public void setName(String newName)
{
name = newName;
}
/**
* Return the name of this person.
*/
public String getName()
{
return name;
}
/**
* Set a new birth year for this person.
*/
public void setYearOfBirth(int newYearOofBirth)
{
yearOfBirth = newYearOofBirth;
}
/**
* Return the birth year of this person.
*/
public int getYearOfBirth()
{
return yearOfBirth;
}
/**
* Return a string representation of this object.
*/
public String toString() // redefined from "Object"
{
return "Name: " + name + "\n" +
"Year of birth: " + yearOfBirth + "\n";
}
}

View File

@@ -0,0 +1,29 @@
BlueJ example project "people"
Copyright (c) Michael K<>lling, Monash University, 1999-2000
This is a very simple BlueJ demo project. It illustrates some aspects of
object-orientation as well as aspects of BlueJ.
This project is distributed with the BlueJ system to serve as an introductory
practice example. It is referred to in the BlueJ tutorial. Please read the
tutorial (which you can get by selecting "BlueJ Tutorial..." from the Help
menu ion the BlueJ main window) for more detailed information.
You can use this project as follows:
- create a few Staff or Student obejcts
- create a Database object
- use "addPerson" in Database to add the persons you have created previously
from the object bench to the database
- use the "listAll" from the database object to list the contents of the
database.
This project illustrates:
- object creation
- relationship class-object (create _more then one_ object!)
- instance data (use "Inspect" on the objects)
- methods, parameters
- composition
- ...

View File

@@ -0,0 +1,14 @@
#BlueJ class context
comment0.target=Staff()
comment0.text=\nCreate\ a\ staff\ member\ with\ default\ settings\ for\ detail\ information.\n\n
comment1.params=name\ yearOfBirth\ roomNumber
comment1.target=Staff(String,\ int,\ String)
comment1.text=\nCreate\ a\ staff\ member\ with\ given\ name,\ year\ of\ birth\ and\ room\nnumber.\n\n
comment2.params=newRoom
comment2.target=void\ setRoom(String)
comment2.text=\nSet\ a\ new\ room\ number\ for\ this\ person.\n\n
comment3.target=String\ getRoom()
comment3.text=\nReturn\ the\ room\ number\ of\ this\ person.\n\n
comment4.target=String\ toString()
comment4.text=\nReturn\ a\ string\ representation\ of\ this\ object.\n\n
numComments=5

View File

@@ -0,0 +1,56 @@
/**
* A class representing staff members for a simple BlueJ demo program.
*
* @author Michael Kolling
* @version 1.0, January 1999
*/
class Staff extends Person
{
private String room;
/**
* Create a staff member with default settings for detail information.
*/
Staff()
{
super("(unknown name)", 0000);
room = "(unknown room)";
}
/**
* Create a staff member with given name, year of birth and room
* number.
*/
Staff(String name, int yearOfBirth, String roomNumber)
{
super(name, yearOfBirth);
room = roomNumber;
}
/**
* Set a new room number for this person.
*/
public void setRoom(String newRoom)
{
room = newRoom;
}
/**
* Return the room number of this person.
*/
public String getRoom()
{
return room;
}
/**
* Return a string representation of this object.
*/
public String toString() // redefined from "Person"
{
return super.toString() +
"Staff member\n" +
"Room: " + room + "\n";
}
}

View File

@@ -0,0 +1,11 @@
#BlueJ class context
comment0.target=Student()
comment0.text=\nCreate\ a\ student\ with\ default\ settings\ for\ detail\ information.\n\n
comment1.params=name\ yearOfBirth\ studentID
comment1.target=Student(String,\ int,\ String)
comment1.text=\nCreate\ a\ student\ with\ given\ name,\ year\ of\ birth\ and\ student\ ID\n\n
comment2.target=String\ getStudentID()
comment2.text=\nReturn\ the\ student\ ID\ of\ this\ student.\n\n
comment3.target=String\ toString()
comment3.text=\nReturn\ a\ string\ representation\ of\ this\ object.\n\n
numComments=4

View File

@@ -0,0 +1,52 @@
/**
* A class representing students for a simple BlueJ demo program.
*
* @author Michael Kolling
* @version 1.0, January 1999
*/
class Student extends Person
{
private String SID; // student ID number
/**
* Create a student with default settings for detail information.
*/
Student()
{
super("(unknown name)", 0000);
SID = "(unknown ID)";
}
/**
* Create a student with given name, year of birth and student ID
*/
Student(String name, int yearOfBirth, String studentID)
{
super(name, yearOfBirth);
SID = studentID;
}
/**
* Return the student ID of this student.
*/
public String getStudentID()
{
return SID;
}
/**
* Return a string representation of this object.
*/
public String toString() // redefined from "Person"
{
return super.toString() +
"Student\n" +
"Student ID: " + SID + "\n";
}
}

View File

@@ -0,0 +1,40 @@
#BlueJ package file
dependency1.from=Database
dependency1.to=Person
dependency1.type=UsesDependency
package.editor.height=292
package.editor.width=427
package.editor.x=508
package.editor.y=119
package.numDependencies=1
package.numTargets=4
package.showExtends=true
package.showUses=true
target1.height=50
target1.name=Student
target1.showInterface=false
target1.type=ClassTarget
target1.width=80
target1.x=230
target1.y=190
target2.height=50
target2.name=Staff
target2.showInterface=false
target2.type=ClassTarget
target2.width=80
target2.x=110
target2.y=190
target3.height=50
target3.name=Database
target3.showInterface=false
target3.type=ClassTarget
target3.width=80
target3.x=70
target3.y=20
target4.height=50
target4.name=Person
target4.showInterface=false
target4.type=AbstractTarget
target4.width=80
target4.x=170
target4.y=90

View File

@@ -0,0 +1,3 @@
#Submitter per project properties
#Wed Nov 22 13:05:44 EST 2006
selectedNode=Submission by email