Quick Index
Overview


As always, before we start a challenge, we want to browse and work through the chapter (this chapter). Try to go slowly/iteratively through the chapter.

Directories and files are the bread and butter of programming projects.

In this assignment we will shore up our directory and file skills.

You will be given a list of elements (directories and files) to create, locations (directories) in which to place those elements, and contents to put in the files (file contents).

Objectives


The objectives of this assignment are (relative to Java):


Note: by "JAVA" file we mean a file ending in extension "java", e.g. "Foo.java"

GOTCHAS 🐞



Step 1 - Create Directories


First create your project root directory (RD):


Then create the following directories:


Note: We will also refer to the working directory as the "project root directory" or "root directory".

Step 2 - Create Files in the 'foods' Directory


Add the following files to the "foods" directory.

Fruit.java
Add the file "Fruit.java".
Copy the contents shown to the right into the file.
Save the file.
package a.foods;

public class Fruit {

	public String toString() {
		return "I am a fruit!";
	}

}
Vegetable.java
Add the file "Vegetable.java".
Copy the contents shown to the right into the file.
Save the file.
package a.foods;

public class Vegetable {

	public String toString() {
		return "I am a vegetable!";
	}

}


Step 3 - Create Files in the 'places' Directory


Add the following files to the "places" directory.

Continent.java
Add the file "Continent.java".
Copy the contents shown to the right into the file.
Save the file.
package a.places;

public class Continent {

	public String toString() {
		return "I am a continent (larger type of place)!";
	}

}
City.java
Add the file "City.java".
Copy the contents shown to the right into the file.
Save the file.
package a.places;

public class City {

	public String toString() {
		return "I am a city.";
	}

}


Step 4 - Create Files in the 'geography' Directory


Add the following files to the "geography" directory.

Mountain.java
Add the file "Mountain.java".
Copy the contents shown to the right into the file.
Save the file.
package b.geography;

public class Mountain {

	public String toString() {
		return "There is nothing more attractive than a mountain!";
	}

}
River.java
Add the file "River.java".
Copy the contents shown to the right into the file.
Save the file.
package b.geography;

public class River {

	public String toString() {
		return "Rivers are so beautiful";
	}

}


Step 5 - Create File in the 'tests' Directory


Add the following file to the "tests" directory.

Play.java
Add the file "Play.java".
Copy the contents shown to the right into the file.
Save the file.
package tests;

import a.foods.Fruit;
import a.foods.Vegetable;
import a.places.Continent;
import a.places.City;
import b.geography.River;
import b.geography.Mountain;

public class Play {

	public static void main(String[] args) {
		Play player = new Play();
		player.go();
	}

	public static void println(Object o) {
		System.out.println(o != null ? o.toString() : "");
	}

	public void go() {

		Fruit banana = new Fruit();
		println(banana);
		Vegetable kale = new Vegetable();
		println(kale);
		Continent africa = new Continent();
		println(africa);
		City tokyo = new City();
		println(tokyo);
		Mountain westBond = new Mountain();
		println(westBond);
		River yangtze = new River();
		println(yangtze);

	}


}


Step 6 - Create Files in the Project Root Directory


Add the following files to the project root directory.

compile.bat
Add the file "compile.bat".
Copy the contents shown to the right into the file.
Save the file.
echo off

javac -classpath "." a/foods/*.java
javac -classpath "." a/places/*.java
javac -classpath "." b/geography/*.java
javac -classpath "." tests/Play.java

pause
run.bat
Add the file "run.bat".
Copy the contents shown to the right into the file.
Save the file.
echo off

java -classpath "." tests/Play

pause


Submitting



Grading


Typically we use standard rubrics (grading rules). However, this assignment is atypical, therefore it will have these specific grading rules:


Notes:
For this assignment, you do not need to compile or run any JAVA files. You do not need to run the BAT files. For future assignments, we will be compiling and running.