Added dropbox12 and 13

This commit is contained in:
Scott 2025-09-22 22:10:48 -07:00
parent 27dab22a7a
commit 60a53b4331
13 changed files with 370 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/.metadata/

10
dropbox12/.classpath Normal file
View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path=""/>
<classpathentry kind="output" path=""/>
</classpath>

17
dropbox12/.project Normal file
View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>dropbox12</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8

3
dropbox12/dropbox12/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
/Student.class
/student.class
/StudentTest.class

View File

@ -0,0 +1,66 @@
/**
* Assignment 12
* Course: CISS238
* Student: Scott Steely
* Date: Sep 22, 2025
*/
package dropbox12;
import java.util.ArrayList;
import java.util.Collections;
public class Student {
// fileds
private String name;
private ArrayList<String> courses;
//accessors
public String getName() {
return name;
}
public ArrayList<String> getCourses() {
return courses;
}
// mutators
public void setName(String name) {
this.name = name;
}
public void setCourses(ArrayList<String> courses) {
this.courses = courses;
}
// constructors
public Student(String name, ArrayList<String> courses) {
this.name = name;
this.courses = courses;
}
// methods
public void addCourse(String course) {
getCourses().add(course);
}
public void removeCourse(String course) {
getCourses().remove(course);
}
public void sortCourses() {
Collections.sort(getCourses());
}
public int findCoursePosition(String course) {
return getCourses().indexOf(course) + 1;
}
public boolean isCourseCompleted(String course) {
return getCourses().contains(course);
}
// toString
@Override
public String toString() {
String str;
str = String.format("Name: %s%n$d courses%n", getName(), getCourses().size());
for(String c:getCourses()) {
str += String.format("%s, ", c);
}
return str;
}
}

View File

@ -0,0 +1,86 @@
/**
* Assignment 12
* Course: CISS238
* Student: Scott Steely
* Date: Sep 22, 2025
*/
package dropbox12;
import java.util.ArrayList;
import java.util.Scanner;
public class StudentTest {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
// variables
String name;
String course;
// two courses in an ArrayList
ArrayList<String> myCourses = new ArrayList<>();
myCourses.add("CS 101");
myCourses.add("CS 102");
// prompt user for input
System.out.println("Enter student name: ");
name = input.nextLine();
// create a student with the two courses
Student student = new Student(name, myCourses);
int menuSelected;
// display a user menu
System.out.println("Enter a number for the task:");
System.out.println("1. Add a course.");
System.out.println("2. Drop a course.");
System.out.println("3. Find the position of a course.");
System.out.println("4. Display all courses.");
System.out.println("5. Sort courses.");
System.out.println("6. Exit.");
menuSelected = input.nextInt();
input.nextLine();
while(menuSelected > 0 && menuSelected <6) {
switch(menuSelected) {
case 1:
System.out.println("Enter a course: ");
course = input.nextLine();
student.addCourse(course);
System.out.println("Course added.");
break;
case 2:
System.out.println("Enter a course to delete:");
course = input.nextLine();
student.removeCourse(course);
System.out.println("Course dropped.");
break;
case 3:
System.out.println("Enter a course to see its position: ");
course = input.nextLine();
// check if the course is in the completed list
if(student.isCourseCompleted(course)) {
System.out.printf("%s is in position %d%n",
course, student.findCoursePosition(course));
} else {
System.out.printf("%s is not completed yet.", course);
}
break;
case 4:
System.out.println(student);
break;
case 5:
student.sortCourses();
System.out.println(student);
}
// display a user menu
System.out.println("Enter a number for the task:");
System.out.println("1. Add a course.");
System.out.println("2. Drop a course.");
System.out.println("3. Find the position of a course.");
System.out.println("4. Display all courses.");
System.out.println("5. Sort courses.");
System.out.println("6. Exit.");
menuSelected = input.nextInt();
input.nextLine();
}
input.close();
}
}

10
dropbox13/.classpath Normal file
View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path=""/>
<classpathentry kind="output" path=""/>
</classpath>

17
dropbox13/.project Normal file
View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>dropbox13</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8

2
dropbox13/dropbox13/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/Employee.class
/EmployeeTest.class

View File

@ -0,0 +1,67 @@
/**
* Assignment 13
* Skill: CISS238
* Student: Scott Steely
* Date: Sep 22, 2025
*/
package dropbox13;
import java.util.ArrayList;
import java.util.Collections;
public class Employee{
// fileds
private String name;
private ArrayList<String> skills;
//accessors
public String getName() {
return name;
}
public ArrayList<String> getSkills() {
return skills;
}
// mutators
public void setName(String name) {
this.name = name;
}
public void setSkills(ArrayList<String> skills) {
this.skills = skills;
}
// constructors
public Employee(String name, ArrayList<String> skills) {
this.name = name;
this.skills = skills;
}
// methods
public void addSkill(String skill) {
getSkills().add(skill);
}
public void removeSkill(String skill) {
getSkills().remove(skill);
}
public void sortSkills() {
Collections.sort(getSkills());
}
public int findSkillPosition(String skill) {
return getSkills().indexOf(skill) + 1;
}
public boolean isSkillCompleted(String skill) {
return getSkills().contains(skill);
}
// toString
@Override
public String toString() {
String str;
str = String.format("Name: %s%nSkills :%n", getName(), getSkills().size());
for(String c:getSkills()) {
str += String.format("%s, ", c);
}
return str;
}
}

View File

@ -0,0 +1,87 @@
/**
* Assignment 13
* Skill: CISS238
* Employee: Scott Steely
* Date: Sep 22, 2025
*/
package dropbox13;
import java.util.ArrayList;
import java.util.Scanner;
public class EmployeeTest {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
// variables
String name;
String skill;
// two skills in an ArrayList
ArrayList<String> mySkills = new ArrayList<>();
mySkills.add("Diviner/Dowser");
mySkills.add("Alchemist");
// prompt user for input
System.out.println("Enter employee name: ");
name = input.nextLine();
// create a employee with the two skills
Employee employee = new Employee(name, mySkills);
int menuSelected;
// display a user menu
System.out.println("Enter a number for the task:");
System.out.println("1. Add a skill.");
System.out.println("2. Drop a skill.");
System.out.println("3. Find the position of a skill.");
System.out.println("4. Display all skills.");
System.out.println("5. Sort skills.");
System.out.println("6. Exit.");
menuSelected = input.nextInt();
input.nextLine();
while(menuSelected > 0 && menuSelected <6) {
switch(menuSelected) {
case 1:
System.out.println("Enter a skill: ");
skill = input.nextLine();
employee.addSkill(skill);
System.out.println("Skill added.");
break;
case 2:
System.out.println("Enter a skill to delete:");
skill = input.nextLine();
employee.removeSkill(skill);
System.out.println("Skill dropped.");
break;
case 3:
System.out.println("Enter a skill to see its position: ");
skill = input.nextLine();
// check if the skill is in the completed list
if(employee.isSkillCompleted(skill)) {
System.out.printf("%s is in position %d%n",
skill, employee.findSkillPosition(skill));
} else {
System.out.printf("%s is not completed yet.", skill);
}
break;
case 4:
System.out.println(employee);
break;
case 5:
employee.sortSkills();
System.out.println(employee);
}
// display a user menu
System.out.println("Enter a number for the task:");
System.out.println("1. Add a skill.");
System.out.println("2. Drop a skill.");
System.out.println("3. Find the position of a skill.");
System.out.println("4. Display all skills.");
System.out.println("5. Sort skills.");
System.out.println("6. Exit.");
menuSelected = input.nextInt();
input.nextLine();
}
input.close();
}
}