Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TOPIC 1: Object-Oriented Programming - MASTER ISSUE #1

Closed
18 tasks done
alyeffy opened this issue Oct 12, 2018 · 8 comments
Closed
18 tasks done

TOPIC 1: Object-Oriented Programming - MASTER ISSUE #1

alyeffy opened this issue Oct 12, 2018 · 8 comments
Labels
1 Object-Oriented Program Design post Things to do after class prep Things to do before the next class
Milestone

Comments

@alyeffy
Copy link
Owner

alyeffy commented Oct 12, 2018

LAST UPDATED: 12 OCT 2018

General inquiries and updates relating to Topic 1 will be updated on this issue.

WEEK DATE DETAILS PREP LECTURE NOTES ASSIGNMENT(S) LAB
01 05/10/2018 Intro to the Java language, Object-Oriented Programs, and Basic Program Design Approaches here
02 16/10/2018 Elementary Java Syntax, Data Representation, and Bit Conversion here
03 23/10/2018 Inheritance and Polymorphism here
04 30/10/2018 Abstract Classes, Interfaces, and UML Diagrams here

LESSON 01 - 05/10/2018

Intro to the Java language, Object-Oriented Programs, and Basic Program Design Approaches

PREP:

  • N/A

ASSIGNMENTS:

  • If you did the Pokeball class definition on paper in class, do the Trainer class definition on paper and place it in my pigeonhole before the next class. You can check it against my Pokeball.java example.
  • If you did the Trainer class definition on paper in class, do the Pokeball class definition on paper and place it in my pigeonhole before the next class. You can check it against my Trainer.java example.
  • Make sure you label all the constructors, methods, variables, etc. accordingly (see Pokemon.java as an example)
  • For the Node.java and Path.java classes, follow the TODO instructions, e.g. label the types of constructors, methods, variables etc. using the same style as the Pokemon.java class

LAB:

  • N/A

LESSON 02 - 16/10/2018

Elementary Java Syntax, Data Representation, and Bit Conversion

PREP:

  • Follow the instructions in the SETUP_and_WORKFLOW.md file to set up the development environment and workflow needed for the course. If you encounter any problems along the way, comment below. We will be spending a few minutes at the beginning of the next class going over any setup problems you can't resolve (i.e.bring your laptop to class).
  • Comment below your name, your favourite food, and something you would like to learn how to program (e.g. a game, a website etc.) (Follow my example comment below).

ASSIGNMENTS:

  • N/A

LAB:

  • N/A

LESSON 03 - 23/10/2018

Inheritance and Polymorphism

PREP:

  • Continue working on any of the Eclipse, GitHub setup etc. and bring any issues you have to class

ASSIGNMENTS:

  • Read over Activity 2 of the Elevens Lab
  • Based on what we did for the Card.java (solution) class in our first lab last lesson, complete the isEmpty and size accessor methods. HINT: You will need to use one of the methods from the AP Exam Java Quick Reference

LAB:


LESSON 04 - 30/10/2018

Abstract Classes, Interfaces, and UML Diagrams

PREP:

  • Review the lecture notes for lessons 1-3 as we will be working on some questions in class

ASSIGNMENTS:

  • Odd-numbered questions from the Classes and Objects MCQ set
  • (optional) Even-numbered questions from the Classes and Objects MCQ set

LAB:

@alyeffy alyeffy added the 1 Object-Oriented Program Design label Oct 12, 2018
@alyeffy
Copy link
Owner Author

alyeffy commented Oct 12, 2018

I'm Alyssa, my favourite food is sushi 🍣 , and I would like to learn how to implement machine learning using TensorFlow!

@AllenZoo
Copy link

I'm Allen, my favourite food is fried chicken and poutine, and I would like to learn how to program a 2D platformer game.

@Kevin-Tan25
Copy link

I'm Kevin, my favourite food is ramen, and I would like to learn how to create a simple A.I.

@alyeffy alyeffy closed this as completed Oct 23, 2018
@alyeffy alyeffy reopened this Oct 23, 2018
@alyeffy
Copy link
Owner Author

alyeffy commented Oct 29, 2018

@AllenZoo @Kevin-Tan25 @RuthlessDebugMachine if you have any questions about assignments, labs, technical issues or general course material for topic 1, you can comment them on this issue thread :)

@RuthlessDebugMachine
Copy link

Hi Alyssa, I am Howard. I just met a problem. If I want to track 40 previous random number seeds and save them and still updating them while the program is running, can you briefly tell me what the method would be? like the type, brief structure of implements etc. I remember that we seemed have gone over this in class but I did not actually catch on well, thanks!

@alyeffy
Copy link
Owner Author

alyeffy commented Nov 9, 2018

Hi @RuthlessDebugMachine, just to clarify, is there a specific way you want to create these random seeds? And as you are updating them, are you simply calling the same random function again to retrieve new values to save to these variables?

@RuthlessDebugMachine
Copy link

@alyeffy ,yes, by using Math.Random() method, and it is calling the same method again and again.

@alyeffy
Copy link
Owner Author

alyeffy commented Nov 10, 2018

@RuthlessDebugMachine so since the method is constantly updating values and not returning anything, it sounds like it is a mutator. A simple implementation for this could be to create an empty array of doubles of length 40, then call the Math.random() function 40 times using a for loop, assigning each value to an index in the array. This way, you could access each specific number in the list when needed using standard array access. You could even use a specific collection rather than an array, depending on your needs. However, you need to specify how frequently you want to update them while the program is running as well. In other words, it needs a condition (e.g. a certain amount of time has passed) that has to be met before the seeds are updated. Depending on the condition, an observer/event listener design pattern might be useful for this as well. Design patterns and Collections are not part of the AP subset, so I have a simple implementation below:

// I am assuming that your class has the following data fields:
public double[] seeds; // an array of doubles storing the values of the seeds
public boolean needsUpdate; // a boolean indicating whether or not the seeds need to be updated

// Creates a class object with an empty seeds array and updates them right away.
public ClassName() {
    this.seeds = new double[40]; // initializes an empty array of doubles of length 40
    updateSeeds(); // updates the seeds
}

// Updates the seeds in the seeds data field and then sets needsUpdate to false
public void updateSeeds() {
    for (int i = 0; i < this.seeds.length(); i++) {
        this.seeds[i] = Math.random(); // replaces existing seed values with new ones
    }
    this.needsUpdate = false; // sets the update flag to false since seeds were just updated
}

// Checks whether of not the seeds need to be updated based on the condition
public void checkUpdate() { 
    if (condition) // depending on your condition, this method might have parameters that need to be taken into account for the condition
        this.needsUpdate = true;
}

public void main() { // remember that the main function is always run first
    ClassName x = new ClassName(); // instantiation of the class

    while (x.getUpdateFlag() == false) { // updateSeeds always starts as false because of the constructor
        x.checkUpdate(); // changes needsUpdate to true if update condition is met
        if (x.getUpdateFlag()) // if needsUpdate is true (I left the self-explanatory implementation for this getter out)
            x.updateSeeds(); // updates the seeds and sets needsUpdate to false again
        // end of while loop body, and since needsUpdate is guaranteed to be false by the end, an infinite loop ensues
        // this ensures that the seeds are constantly being checked if they need to be updated and are updated when they do
    }
}

@alyeffy alyeffy added prep Things to do before the next class post Things to do after class labels Jan 14, 2019
@alyeffy alyeffy added this to the Topic 1 Items milestone Jan 21, 2019
@alyeffy alyeffy closed this as completed Jan 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1 Object-Oriented Program Design post Things to do after class prep Things to do before the next class
Projects
None yet
Development

No branches or pull requests

4 participants