Week 1: January 24 and 26, 2007
Week 2: January 29 and 31. February 2, 2007
Subject: Campus Dialup Service to End June 30, 2007 The campus modem pool was originally created to enable faculty, staff, and students to have remote access to the campus network at a time when commercial dialup options were limited or unavailable. Eventually, this remote access service evolved to provide Internet access. The vast majority of users have switched to other commercial options over the years, and the modem pool usage has declined dramatically. Because of this decreased usage and the availability of other options, the number of modems supporting the campus dialup service is continually being reduced. OIT will eliminate dialup service completely on June 30, 2007. For more information, contact: OIT Help Desk, 301.405.1500 oit@umd.edu www.oit.umd.edu/News/Archive/2007/endofservice_dialup.html
Week 3: February 5, 7, and 9, 2007
Site IP addresses -------------------------------------------------- wam.umd.edu 128.8.10.141 128.8.10.142 128.8.10.143 glue.umd.edu 128.8.10.68 128.8.10.71 --------------------------------------------------
Week 4: February 12, 14, and 16, 2007
Unix Commands -------------------------------------------------------------------------------- 1. cd <-- change to home directory 2. cd file1 <-- change to directory file1 3. ls and ls -ls and ls -tl <-- list contents of a directory 4. mkdir file1 <-- make a directory called file1 5. rmdir file1 <-- remove directory file1 6. cp file1 file2 <-- copy file1 to file2 7. mv file1 file2 <-- move file1 to file2 -------------------------------------------------------------------------------- Note. Directories cannot be removed unless they are empty. Let's suppose that you have created a file and now you want to remove it. Try: 8. rm file1 <-- remoove/delete file1 Text editor commands -------------------------------------------------------------------------------- 1. vi filename <-- use vi editor to change contents of filename. For example, the command sequence: prompt >> cd ../pub prompt >> vi Welcome.html prompt >> vi resume.html prompt >> vi ce-systems.html moves your shell to the public directory and then systemantically creates the HTML files for your home page, resume and trip page. Notice that each file name has the "html" extension -- web browsers need this information. The class reader contains a list of basic editor commands. --------------------------------------------------------------------------------
Week 4: February 19, 21, and 23, 2007
Week 5: February 26, 28, and March 2, 2007
Week 6: March 5, 7, and 9, 2007
Week 7: March 12, 14, and 16, 2007
Week 8: March 19-24, 2007
Week 9: March 26, 28, and 30, 2007
Weeks 10-11: April 2 through 13, 2007
Week 13: April 23, 25 and 27.
Week 14: April 30, May 2 and 4, 2007
Week 15: May 7 and 9, 2007
Here are a few hints for the homework ... I realize that we are running out of time, so just do as much as you can and hand everything in first thing on Wednesday Morning.
This problem is quite straightforward. Put all of your code in one file called FoldedBox.java. Here is a sample of my output:
Script started on Sun May 6 18:30:37 2007 prompt >> prompt >> java FoldedBox FoldedBox: Match Volume = 1.0 Surface Area = 5.0 .... details of Shoe, Packing, and Gift removed .... FoldedBox: Dumpster Volume = 165888.0 Surface Area = 14976.0 prompt >> exit Script done on Sun May 6 18:30:46 2007
The source code is similar in style to DataArray.java on the "java examples" web page.
My solution is composed of two files:
FoldedBoxArray.java FoldedBox.java.
For the latter you can use exactly the same file as written in Question 1.
FoldedBoxArray.java creates an array list of box objects, adds them to the array list, and then sorts them in the required ways. You can find an example of the Collections sort() code in Family.java on the java examples web page. The only tricky thing about this problem is that in order for the Collections sort() to work, you actually have to create an object of type FoldedBoxArray. To help you get started, here is an abbreviated solution:
import java.util.*; import java.util.ArrayList; import java.util.Iterator; import java.util.List; public class FoldedBoxArray { ArrayList boxes = new ArrayList(); // Sort boxes by surface area .... public void sortBySurfaceArea() { Collections.sort( boxes, new areaCompare() ); } class areaCompare implements Comparator { ... fill in details here ... } // Sort boxes by volume .... ... fill in details here ... // =========================================================== // Create an array list of folded box objects .... // =========================================================== public static void main ( String args [] ) { // Create an object of type folded box array .... FoldedBoxArray fba = new FoldedBoxArray(); // Create and initialize folded box objects FoldedBox fbMatch = new FoldedBox ("Match", 2.0, 1.0, 0.5 ); ... fill in details here ... // Add boxes to the array list ..... fba.boxes.add( fbMatch ); ... fill in details here ... // Walk along unsorted list and print details .... System.out.println("Open folded boxes "); System.out.println("============================="); ... fill in details here ... // Sort and print list by volume... fba.sortByVolume(); ... fill in details here ... etc .... } }
Here is a fragment of the output generated by my solution:
rompt >> java FoldedBoxArray Open folded boxes ============================= FoldedBox: Match Volume = 1.0 Surface Area = 5.0 .... Output is as for question 1..... FoldedBox: Dumpster Volume = 165888.0 Surface Area = 14976.0 Folded boxes sorted by volume ============================= FoldedBox: Match Volume = 1.0 Surface Area = 5.0 FoldedBox: Shoe Volume = 672.0 Surface Area = 376.0 FoldedBox: Gift Volume = 720.0 Surface Area = 384.0 .. etc...
My apologies, when I sat down to do the solution to this question I realised that it would make much more sense to have an object of type Footprint and then just simply set the footprint name to "AV Williams Bldg". Here is a schematic of my solution:
import java.util.ArrayList; import java.util.Iterator; import java.util.List; public class Footprint { String sName; List triangle = new ArrayList(); // ============================================== // Set name of the footprint ... // ============================================== public void setName( String sName ) { ... fill in details here ... } // ============================================== // Compute total area of footprint .... // ============================================== public double area() { double buildingArea = 0.0; // Walk along triangles and sum area .... .... fill in details here .... return buildingArea; } // ============================================== // Compute x coordinate of centroid .... // ============================================== public double getCentroidX() { double buildingArea = area(); double firstMomentX = 0.0; // Compute first moment of area about origin ... .... fill in details here .... return firstMomentX/buildingArea; } // ============================================== // Compute y coordinate of centroid .... // ============================================== public double getCentroidY() { .... fill in details here .... } // ============================================== // Create string description of the footprint ... // ============================================== public String toString() { String s = "Footprint: " + sName + "\n"; ... fill in details here .... return s; } // ======================================================= // Exercise methods in Footprint class ..... // ======================================================= public static void main( String args[] ) { // Create building footprint object .... Footprint avw = new Footprint(); avw.setName("A.V. Williams Bldg"); // Create triangles to cover the footprint ... Triangle a = new Triangle("a", 1.0, 1.0, 1.0, 6.0, 3.0, 1.0 ); .... fill in details here ... // Add triangles to footprint ... avw.triangle.add( a ); .... fill in details here ... // Print details of footprint, its area and centroid .... System.out.println ( avw.toString() ); System.out.printf ( "*** Footprint Area = %8.3f\n", avw.area() ); System.out.printf ( "*** Centroid: X = %8.3f\n", avw.getCentroidX() ); System.out.printf ( " : Y = %8.3f\n", avw.getCentroidY() ); } }
The pair of statements:
Footprint avw = new Footprint(); avw.setName("A.V. Williams Bldg");
and then sets the name to "AV Williams Bldg." You will need to fill in the details of setName() -- it's only one line of code.
Each footprint object contains an arraylist of Triangle objects. To save space, I use the fancy constructor in Triangle.java, namely:
Triangle a = new Triangle("a", 1.0, 1.0, 1.0, 6.0, 3.0, 1.0 );
Then to add the triangle to the array list, simply type:
avw.triangle.add( a );
This statement basically says "go to the footprint object referenced by avw, look inside and find the variable called triangle. In this case, triangle is a List. Then add the reference to triangle "a" to the arraylist.
A summary of my output is as follows:
Script started on Sun May 6 22:36:54 2007 prompt >> prompt >> java Footprint Footprint: A.V. Williams Bldg ================================= Triangle: "a" ================================= Edge("e1") connects nodes (n3, n1) Edge("e2") connects nodes (n1, n2) Edge("e3") connects nodes (n2, n3) Node("n3") is at (1.0,1.0) Node("n1") is at (1.0,6.0) Node("n2") is at (3.0,1.0) .... details of triangles b-f removed .... *** Footprint Area = 28.000 *** Centroid: X = 5.000 : Y = 3.929 prompt >> prompt >> exit Script done on Sun May 6 22:37:01 2007
Week 17: .....
Developed in January 2007 by Mark Austin
Copyright © 2007, Department of Civil and Environmental Engineering,
University of Maryland