update q2

This commit is contained in:
SowinskiBraeden committed 2025-04-03 18:28:41 -07:00
1 parent b2c86ec9b6
commit 0ea524b392
4 files changed
+59 -39

No files matched your search

+11
View File
@@ -20,4 +20,15 @@
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
</natures>
<filteredResources>
<filter>
<id>1743547762235</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>
@@ -103,5 +103,38 @@ public class TimeSheet {
this.details.add(row);
}
/**
* main program entry to show it works.
* @param args unused
*/
public static void main(String[] args) {
TimeSheet sheet = new TimeSheet();
final float hours1 = 2;
final float hours2 = 32 / 10;
final float hours3 = 38 / 10;
final int id3 = 3;
sheet.addRow(new TimeSheetRow(
1,
"assignment1",
hours1, hours2, hours3
));
sheet.addRow(new TimeSheetRow(
2,
"assignment2",
hours3, hours2, hours1
));
sheet.addRow(new TimeSheetRow(
id3,
"assignment3",
hours2, hours3, hours1
));
System.out.println(sheet.toString());
}
}
@@ -9,29 +9,26 @@ public class TimeSheetRow {
/** MASK of bits for days of week represented inside hours long. */
private static final long[] MASK = {
0xFFL, 0xFF00L, 0xFF0000L,
0xFF000000L, 0xFF00000000L,
0xFF0000000000L, 0xFF000000000000L
0xFFL, 0x00L, 0x0000L,
0x000000L, 0x00000000L, 0x0000000000L,
0x000000000000L, 0x00000000000000L
};
/** UMASK to unmask stuff. */
private static final long[] UMASK = {
0xFFFFFFFFFFFFFF00L,
0xFFFFFFFFFFFF00FFL,
0xFFFFFFFFFF00FFFFL,
0xFFFFFFFF00FFFFFFL,
0xFFFFFF00FFFFFFFFL,
0xFFFF00FFFFFFFFFFL,
0xFFFFFFFFFFFFFF00L, 0xFFFFFFFFFFFF00FFL,
0xFFFFFFFFFF00FFFFL, 0xFFFFFFFF00FFFFFFL,
0xFFFFFF00FFFFFFFFL, 0xFFFF00FFFFFFFFFFL,
0xFF00FFFFFFFFFFFFL
};
/** DECI to convert hours. */
private static final float DECI = 10;
/** baseHex to convert hexidecimal */
/** baseHex to convert hexidecimal. */
private static final int HEX_BASE = 16;
/** SHIFT by bits */
/** SHIFT by bits. */
private static final int SHIFT = 8;
/** project number as int. */
@@ -52,7 +49,7 @@ public class TimeSheetRow {
this.hours = 0;
}
/**4
/**
* TimeSheetRow constructor.
* @param projectNumber int
* @param workPackage String
@@ -143,32 +140,9 @@ public class TimeSheetRow {
* @param hour float
*/
public void setHour(int day, float hour) {
// long encoded = ((long) (hour * DECI) | MASK[day + 1]) << day * SHIFT;
// this.hours = (this.hours & UMASK[day]) | encoded;
String hex = Integer.toHexString((int) (hour * DECI));
long encoded = Long.parseLong(hex, HEX_BASE) << (day * SHIFT);
long encoded = ((long) (hour * DECI) | MASK[day + 1]) << day * SHIFT;
this.hours = (this.hours & UMASK[day]) | encoded;
}
/**
* main test encode decode.
* @param args unused
*/
public static void main(String[] args) {
final Long n = 0X321420372d0b20L;
TimeSheetRow t = new TimeSheetRow(
0,
"Test",
3.2f, 1.1f, 4.5f, 5.5f, 3.2f, 2.0f, 5.0f
);
System.out.println(Long.toHexString(t.getHours()));
// t.setHour(2, 3.2f);
// t.setHour(4, 5.5f);
for (int i = 0; i < 7; i++) {
t.setHour(i, 3.0f);
System.out.print(t.getHour(i) + " ");
}
}
}
@@ -10,5 +10,7 @@ class TimeSheetRowTest {
void test() {
fail("Not yet implemented");
}
}