Courses implementation

This commit is contained in:
HeshamTB 2019-01-28 13:57:04 +03:00
parent 0d77f9cb8b
commit f97260e256
2 changed files with 15 additions and 5 deletions

View File

@ -19,7 +19,7 @@ public class Location {
public Location(double lat, double lon) { public Location(double lat, double lon) {
latitude = lat; latitude = lat;
longitude = lon; longitude = lon;
city = cityBasedOnIP(); //city = cityBasedOnIP(); //API intansive
} }
public Location() { public Location() {
@ -51,7 +51,7 @@ public class Location {
this.longitude = lon; this.longitude = lon;
} }
private String cityBasedOnIP() { public String cityBasedOnIP() {
String city = ""; String city = "";
try { try {

View File

@ -1,3 +1,6 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner; import java.util.Scanner;
//TODO: save Person as JSON //TODO: save Person as JSON
@ -6,7 +9,6 @@ public class Main {
public static void main(String[] args) { public static void main(String[] args) {
Person p = new Person(12345, "Hesham", Level.BA); Person p = new Person(12345, "Hesham", Level.BA);
System.out.println(p.getLocation().getCity());
System.out.println("-------------------------------------------------"); System.out.println("-------------------------------------------------");
Scanner in = new Scanner(System.in); Scanner in = new Scanner(System.in);
System.out.print("Name: "); System.out.print("Name: ");
@ -19,6 +21,8 @@ public class Main {
p.getEdu().setSchool(in.next()); p.getEdu().setSchool(in.next());
System.out.print("Major: "); System.out.print("Major: ");
p.getEdu().setMajor(in.next()); p.getEdu().setMajor(in.next());
List<Course> list = Arrays.asList(Course.EE201, Course.EE250,Course.ISLS201);
p.getEdu().addCourses(list);
Print(p); Print(p);
} }
@ -48,12 +52,18 @@ public class Main {
*/ */
public static void Print(Person p) { public static void Print(Person p) {
System.out.println( System.out.println(
"\t---------INFO---------\n" "\n\n\n\t---------INFO---------\n"
+ "\tName: "+p.getAccount().getName()+"\n" + "\tName: "+p.getAccount().getName()+"\n"
+ "\tID: "+p.getAccount().getID()+"\n" + "\tID: "+p.getAccount().getID()+"\n"
+ "\tMajor: "+p.getEdu().getMajor()+"\n" + "\tMajor: "+p.getEdu().getMajor()+"\n"
+ "\tSchool: "+p.getEdu().getSchool()+"\n" + "\tSchool: "+p.getEdu().getSchool()+"\n"
+ "\tAccountType: "+p.getAccount().getAccountType()); + "\tCity: "+p.getLocation().cityBasedOnIP()+"\n"
+ "\tAccountType: "+p.getAccount().getAccountType()+"\n"
+ "\t---------COURSES---------");
int i = 1;
for (Course course : p.getEdu().getCourses()) {
System.out.println("\tCourse "+i+": "+course.name());
}
} }