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,42 @@
/**
* Class Address - used to store address details for a post address
*
* @author Michael Kolling
* @version 1.0, January 1999
*/
public class Address
{
private String street;
private String town;
private String postCode;
private String country;
/**
* Construct an Address without country
*/
public Address(String street, String town, String postCode)
{
this(street, town, postCode, "");
}
/**
* Construct an Address with full details
*/
public Address(String street, String town, String postCode, String country)
{
this.street = street;
this.town = town;
this.postCode = postCode;
this.country = country;
}
/**
* Return a string representation of this object.
*/
public String toString()
{
return street + "\n" +
town + " " + postCode + "\n" +
country + "\n";
}
}

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,80 @@
/**
* 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;
private Address address;
/**
* 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 newYearOfBirth)
{
yearOfBirth = newYearOfBirth;
}
/**
* Return the birth year of this person.
*/
public int getYearOfBirth()
{
return yearOfBirth;
}
/**
* Set a new address for this person.
*/
public void setAddress(String street, String town, String postCode)
{
address = new Address(street, town, postCode);
}
/**
* Return the address of this person.
*/
public Address getAddress()
{
return address;
}
/**
* 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,13 @@
BlueJ example project "people2"
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 an extension of "people". It is identical to "people"
except for the addition of an "Address" class and an address attribute
in Person.
This project may be used to study object creation and method calls from
within other object (non-interactive).

View File

@@ -0,0 +1,58 @@
/**
* 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,47 @@
/**
* 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.
*/
public Student()
{
super("(unknown name)", 0000);
SID = "(unknown ID)";
}
/**
* Create a student with given name, year of birth and student ID
*/
public Student(String name, int yearOfBirth, String studentID)
{
super(name, yearOfBirth);
SID = studentID;
}
/**
* Return the stident 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,48 @@
#BlueJ package file
dependency1.from=Person
dependency1.to=Address
dependency1.type=UsesDependency
dependency2.from=Database
dependency2.to=Person
dependency2.type=UsesDependency
package.editor.height=308
package.editor.width=445
package.editor.x=60
package.editor.y=82
package.numDependencies=2
package.numTargets=5
target1.height=50
target1.modifiers=0
target1.name=Student
target1.type=ClassTarget
target1.width=80
target1.x=260
target1.y=220
target2.height=50
target2.modifiers=400
target2.name=Person
target2.type=ClassTarget
target2.width=80
target2.x=190
target2.y=110
target3.height=50
target3.modifiers=0
target3.name=Staff
target3.type=ClassTarget
target3.width=80
target3.x=130
target3.y=220
target4.height=50
target4.modifiers=0
target4.name=Database
target4.type=ClassTarget
target4.width=80
target4.x=60
target4.y=40
target5.height=50
target5.modifiers=0
target5.name=Address
target5.type=ClassTarget
target5.width=80
target5.x=300
target5.y=20